Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化agv配置和客户
This commit is contained in:
@@ -10,9 +10,9 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['web', 'purchase'],
|
'depends': ['web', 'purchase', 'base_setup'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'views/bye_odoo.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'jikimo_frontend/static/src/fields/custom_many2many_checkboxes/*',
|
'jikimo_frontend/static/src/fields/custom_many2many_checkboxes/*',
|
||||||
'jikimo_frontend/static/src/fields/Many2OneRadioField/*',
|
'jikimo_frontend/static/src/fields/Many2OneRadioField/*',
|
||||||
|
# 移除odoo相关标识
|
||||||
|
'jikimo_frontend/static/src/bye_odoo/*',
|
||||||
'jikimo_frontend/static/src/scss/custom_style.scss',
|
'jikimo_frontend/static/src/scss/custom_style.scss',
|
||||||
# 'jikimo_frontend/static/src/views/list_nums/list_nbCols.js',
|
# 'jikimo_frontend/static/src/views/list_nums/list_nbCols.js',
|
||||||
'jikimo_frontend/static/src/views/list_nums/list_nums.xml',
|
'jikimo_frontend/static/src/views/list_nums/list_nums.xml',
|
||||||
|
|||||||
23
jikimo_frontend/data/demo_data.xml
Normal file
23
jikimo_frontend/data/demo_data.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="partner_demo_company" model="res.partner">
|
||||||
|
<field name="name">JKM</field>
|
||||||
|
<field name="street">B-25</field>
|
||||||
|
<field name="city">USA</field>
|
||||||
|
<!-- Use the correct reference or actual ID for the country -->
|
||||||
|
<field name="country_id" ref="base.bd"/>
|
||||||
|
<field name="zip">1229</field>
|
||||||
|
<field name="phone">+8801-712901764</field>
|
||||||
|
<field name="email">info@kolpolok.com</field>
|
||||||
|
<field name="website">www.kolpoloktechnologies.com</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="demo_company" model="res.company">
|
||||||
|
<field name="name">Custom</field>
|
||||||
|
<field name="logo" type="base64" file="kolpolok_custom_title_and_favicon/static/src/img/favicon.ico"/>
|
||||||
|
<field name="favicon" type="base64" file="kolpolok_custom_title_and_favicon/static/src/img/favicon.ico"/>
|
||||||
|
<field name="partner_id" ref="partner_demo_company"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
16
jikimo_frontend/static/src/bye_odoo/extended_user_menu.js
Normal file
16
jikimo_frontend/static/src/bye_odoo/extended_user_menu.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
import { UserMenu } from "@web/webclient/user_menu/user_menu";
|
||||||
|
import { patch } from "@web/core/utils/patch";
|
||||||
|
import { registry } from "@web/core/registry";
|
||||||
|
const userMenuRegistry = registry.category("user_menuitems");
|
||||||
|
|
||||||
|
|
||||||
|
patch(UserMenu.prototype, "legion_hide_odoo.UserMenu", {
|
||||||
|
setup() {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
userMenuRegistry.remove("documentation");
|
||||||
|
userMenuRegistry.remove("support");
|
||||||
|
userMenuRegistry.remove("odoo_account");
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
11
jikimo_frontend/static/src/bye_odoo/favicon.js
Normal file
11
jikimo_frontend/static/src/bye_odoo/favicon.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import { WebClient } from "@web/webclient/webclient";
|
||||||
|
import { patch } from "web.utils";
|
||||||
|
|
||||||
|
patch(WebClient.prototype, "kolpolok_custom_title_and_favicon.WebClient", {
|
||||||
|
setup() {
|
||||||
|
this._super();
|
||||||
|
this.title.setParts({ zopenerp: "JIKIMO" });
|
||||||
|
},
|
||||||
|
});
|
||||||
BIN
jikimo_frontend/static/src/img/favicon.ico
Normal file
BIN
jikimo_frontend/static/src/img/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
jikimo_frontend/static/src/img/jikimo-logo.ico
Normal file
BIN
jikimo_frontend/static/src/img/jikimo-logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
jikimo_frontend/static/src/img/jikimo.ico
Normal file
BIN
jikimo_frontend/static/src/img/jikimo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@@ -83,12 +83,8 @@ patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
|
|||||||
);
|
);
|
||||||
patch(Field.prototype, 'jikimo_frontend.Field', {
|
patch(Field.prototype, 'jikimo_frontend.Field', {
|
||||||
setup() {
|
setup() {
|
||||||
this.FieldComponent = this.props.fieldInfo.FieldComponent;
|
|
||||||
if (!this.FieldComponent) {
|
|
||||||
const fieldType = this.props.record.fields[this.props.name].type;
|
|
||||||
this.FieldComponent = getFieldClassFromRegistry(fieldType, this.props.type);
|
|
||||||
}
|
|
||||||
owl.onMounted(this.setRequired);
|
owl.onMounted(this.setRequired);
|
||||||
|
return this._super(...arguments);
|
||||||
},
|
},
|
||||||
setRequired() {
|
setRequired() {
|
||||||
const id = this.props.id
|
const id = this.props.id
|
||||||
|
|||||||
@@ -3,6 +3,13 @@
|
|||||||
import { registry } from "@web/core/registry";
|
import { registry } from "@web/core/registry";
|
||||||
import { url } from "@web/core/utils/urls";
|
import { url } from "@web/core/utils/urls";
|
||||||
import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field';
|
import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field';
|
||||||
|
import { isBinarySize } from "@web/core/utils/binary";
|
||||||
|
export const fileTypeMagicWordMap = {
|
||||||
|
"/": "jpg",
|
||||||
|
R: "gif",
|
||||||
|
i: "png",
|
||||||
|
P: "svg+xml",
|
||||||
|
};
|
||||||
|
|
||||||
const placeholder = "/web/static/img/placeholder.png";
|
const placeholder = "/web/static/img/placeholder.png";
|
||||||
|
|
||||||
@@ -15,7 +22,7 @@ export class CustomImageField extends ImageField {
|
|||||||
getUrl(previewFieldName) {
|
getUrl(previewFieldName) {
|
||||||
console.log('8888888888886666666666666666666')
|
console.log('8888888888886666666666666666666')
|
||||||
if (this.state.isValid && this.props.value) {
|
if (this.state.isValid && this.props.value) {
|
||||||
if (1) {
|
if (isBinarySize(this.props.value) || this.props.value.length < 50) {
|
||||||
if (!this.rawCacheKey) {
|
if (!this.rawCacheKey) {
|
||||||
this.rawCacheKey = this.props.record.data.__last_update;
|
this.rawCacheKey = this.props.record.data.__last_update;
|
||||||
}
|
}
|
||||||
|
|||||||
35
jikimo_frontend/views/bye_odoo.xml
Normal file
35
jikimo_frontend/views/bye_odoo.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- 修改页面头部图标及文字 -->
|
||||||
|
<template id="favicon_icon" inherit_id="web.layout" name="Web layout">
|
||||||
|
<!-- change the title with reliance partner -->
|
||||||
|
<xpath expr="//head//title" position="before">
|
||||||
|
<title t-esc="'JIKIMO'"/>
|
||||||
|
</xpath>
|
||||||
|
<!-- change the default favicon icon with -->
|
||||||
|
<xpath expr="//head//link[@rel='shortcut icon']" position="replace">
|
||||||
|
<link type="image/x-icon" rel="shortcut icon" href="/jikimo_frontend/static/src/img/jikimo-logo.ico"/>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- hide 登录页面 powerd by odoo 及管理数据库 -->
|
||||||
|
<template id="login_page_layout" inherit_id="web.login_layout" name="Login Page Layout">
|
||||||
|
<xpath expr="//div[@class='card-body']//div[last()]" position="replace"></xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 隐藏odoo版本信息 -->
|
||||||
|
<record id="jikimo_res_config_settings_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">jikimo.res.config.settings.view.form.inherit.base.setup</field>
|
||||||
|
<field name="model">res.config.settings</field>
|
||||||
|
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[@id='about']" position="replace">
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
'views/tool_menu.xml',
|
'views/tool_menu.xml',
|
||||||
'views/menu_fixture_view.xml',
|
'views/menu_fixture_view.xml',
|
||||||
'views/change_base_view.xml',
|
'views/change_base_view.xml',
|
||||||
|
'views/Printer.xml',
|
||||||
|
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
|
|||||||
28
sf_base/commons/Printer.py
Normal file
28
sf_base/commons/Printer.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class Printer(models.Model):
|
||||||
|
_name = 'printer'
|
||||||
|
_description = 'Printer'
|
||||||
|
|
||||||
|
name = fields.Char(string='名称', required=True)
|
||||||
|
ip_address = fields.Char(string='IP 地址', required=True)
|
||||||
|
port = fields.Integer(string='端口', default=9100)
|
||||||
|
|
||||||
|
|
||||||
|
class TableStyle(models.Model):
|
||||||
|
_name = 'table.style'
|
||||||
|
_description = '标签样式'
|
||||||
|
|
||||||
|
name = fields.Char(string='名称', required=True)
|
||||||
|
# todo
|
||||||
|
|
||||||
|
|
||||||
|
class PrinterConfiguration(models.Model):
|
||||||
|
_name = 'printer.configuration'
|
||||||
|
_description = 'Printer Configuration'
|
||||||
|
|
||||||
|
name = fields.Char(string='名称', required=True)
|
||||||
|
printer_id = fields.Many2one('printer', string='打印机')
|
||||||
|
model = fields.Many2one('ir.model', string='模型名称')
|
||||||
|
# # 其他相关字段...
|
||||||
@@ -1 +1,2 @@
|
|||||||
from . import common
|
from . import common
|
||||||
|
from . import Printer
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import time, datetime
|
import time, datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
from odoo import models
|
from odoo import models
|
||||||
|
import socket
|
||||||
|
|
||||||
class Common(models.Model):
|
class Common(models.Model):
|
||||||
_name = 'sf.sync.common'
|
_name = 'sf.sync.common'
|
||||||
@@ -29,3 +29,66 @@ class Common(models.Model):
|
|||||||
d = dt + datetime.timedelta(hours=8)
|
d = dt + datetime.timedelta(hours=8)
|
||||||
nTime = d.strftime("%Y-%m-%d %H:%M:%S")
|
nTime = d.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
return nTime
|
return nTime
|
||||||
|
|
||||||
|
|
||||||
|
class PrintingUtils(models.AbstractModel):
|
||||||
|
_name = 'printing.utils'
|
||||||
|
_description = 'Utility class for printing functionalities'
|
||||||
|
|
||||||
|
def generate_zpl_code(self, code):
|
||||||
|
# 实现生成ZPL代码的逻辑
|
||||||
|
# 初始化ZPL代码字符串
|
||||||
|
zpl_code = "^XA\n"
|
||||||
|
zpl_code += "^CW1,E:SIMSUN.TTF^FS\n"
|
||||||
|
zpl_code += "^CI28\n"
|
||||||
|
|
||||||
|
# 设置二维码位置
|
||||||
|
zpl_code += "^FO50,50\n" # 调整二维码位置,使其与资产编号在同一行
|
||||||
|
zpl_code += f"^BQN,2,6^FDLM,B0093{code}^FS\n"
|
||||||
|
|
||||||
|
# 设置资产编号文本位置
|
||||||
|
zpl_code += "^FO300,60\n" # 资产编号文本的位置,与二维码在同一行
|
||||||
|
zpl_code += "^A1N,45,45^FD编码名称: ^FS\n"
|
||||||
|
|
||||||
|
# 设置{code}文本位置
|
||||||
|
# 假设{code}文本需要位于资产编号和二维码下方,中间位置
|
||||||
|
# 设置{code}文本位置并启用自动换行
|
||||||
|
zpl_code += "^FO300,120\n" # {code}文本的起始位置
|
||||||
|
zpl_code += "^FB400,4,0,L,0\n" # 定义一个宽度为500点的文本框,最多4行,左对齐
|
||||||
|
zpl_code += f"^A1N,40,40^FD{code}^FS\n"
|
||||||
|
|
||||||
|
# 在{code}文本框周围绘制线框
|
||||||
|
# 假设线框的外部尺寸为宽度500点,高度200点
|
||||||
|
# zpl_code += "^FO300,110^GB500,200,2^FS\n" # 绘制线框,边框粗细为2点
|
||||||
|
|
||||||
|
zpl_code += "^PQ1,0,1,Y\n"
|
||||||
|
zpl_code += "^XZ\n"
|
||||||
|
return zpl_code
|
||||||
|
|
||||||
|
def send_to_printer(self, host, port, zpl_code):
|
||||||
|
|
||||||
|
# 实现发送ZPL代码到打印机的逻辑
|
||||||
|
# 将ZPL代码转换为字节串
|
||||||
|
print('zpl_code', zpl_code)
|
||||||
|
zpl_bytes = zpl_code.encode('utf-8')
|
||||||
|
print(zpl_bytes)
|
||||||
|
|
||||||
|
# 创建socket对象
|
||||||
|
mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
try:
|
||||||
|
mysocket.connect((host, port)) # 连接到打印机
|
||||||
|
mysocket.send(zpl_bytes) # 发送ZPL代码
|
||||||
|
print("ZPL code sent to printer successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error with the connection: {e}")
|
||||||
|
finally:
|
||||||
|
mysocket.close() # 关闭连接
|
||||||
|
|
||||||
|
def print_qr_code(self, lot_name, host, port):
|
||||||
|
# 实现打印二维码的逻辑
|
||||||
|
# 这里需要传入 lot_name 参数,因为我们不能直接访问 self.lot_id.name
|
||||||
|
zpl_code = self.generate_zpl_code(lot_name)
|
||||||
|
# 发送ZPL代码到打印机
|
||||||
|
# host = "192.168.50.110" # 可以作为参数传入,或者在此配置
|
||||||
|
# port = 9100 # 可以作为参数传入,或者在此配置
|
||||||
|
self.send_to_printer(host, port, zpl_code)
|
||||||
|
|||||||
@@ -68,98 +68,30 @@ class BasicParametersFixture(models.Model):
|
|||||||
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
|
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
|
||||||
|
|
||||||
code = fields.Char('编码')
|
code = fields.Char('编码')
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
def create_fixture_materials(self, fixture_materials_datas, fixture_model):
|
def _get_basic_parameters_list(self, fixture_materials_data, fixture_materials_name):
|
||||||
fixture_materials_name = fixture_model.fixture_material_id.name
|
|
||||||
if fixture_materials_name == '零点卡盘':
|
if fixture_materials_name == '零点卡盘':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_zero_chuck_param(fixture_materials_data)
|
||||||
self.create(self._json_zero_chuck_param(fixture_materials_data, fixture_model))
|
|
||||||
elif fixture_materials_name == '零点托盘':
|
elif fixture_materials_name == '零点托盘':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_zero_tray_param(fixture_materials_data)
|
||||||
self.create(self._json_zero_tray_param(fixture_materials_data, fixture_model))
|
|
||||||
elif fixture_materials_name == '气动夹具':
|
elif fixture_materials_name == '气动夹具':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_pneumatic_fixture_param(fixture_materials_data)
|
||||||
self.create(self._json_pneumatic_fixture_param(fixture_materials_data, fixture_model))
|
|
||||||
elif fixture_materials_name == '虎钳夹具':
|
elif fixture_materials_name == '虎钳夹具':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_jaw_vice_fixture_param(fixture_materials_data)
|
||||||
self.create(self._json_jaw_vice_fixture_param(fixture_materials_data, fixture_model))
|
|
||||||
elif fixture_materials_name == '磁吸夹具':
|
elif fixture_materials_name == '磁吸夹具':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_magnet_fixture_param(fixture_materials_data)
|
||||||
self.create(self._json_magnet_fixture_param(fixture_materials_data, fixture_model))
|
|
||||||
elif fixture_materials_name == '转接板(锁板)夹具':
|
elif fixture_materials_name == '转接板(锁板)夹具':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_adapter_board_fixture_param(fixture_materials_data)
|
||||||
self.create(self._json_adapter_board_fixture_param(fixture_materials_data, fixture_model))
|
|
||||||
elif fixture_materials_name == '三爪卡盘':
|
elif fixture_materials_name == '三爪卡盘':
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
return self._json_scroll_chuck_param(fixture_materials_data)
|
||||||
self.create(self._json_scroll_chuck_param(fixture_materials_data, fixture_model))
|
return {}
|
||||||
|
|
||||||
def write_fixture_materials(self, fixture_materials_datas, fixture_model):
|
def _json_zero_chuck_param(self, obj):
|
||||||
fixture_materials_name = fixture_model.fixture_material_id.name
|
|
||||||
# cloud夹具物料的code
|
|
||||||
mrs_fixture_materials_codes = []
|
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
|
||||||
mrs_fixture_materials_codes.append(fixture_materials_data.get('code'))
|
|
||||||
# sf夹具物料的code 判断sf夹具型号关联的夹具物料在同步过来的mrs夹具物料中是否存在,不存在则删除
|
|
||||||
sf_materials_model_codes = self._get_sf_materials_model_codes(fixture_model)
|
|
||||||
for sf_materials_model_code in sf_materials_model_codes:
|
|
||||||
if sf_materials_model_code not in mrs_fixture_materials_codes:
|
|
||||||
self.search([('code', '=', sf_materials_model_code)]).sudo().unlink()
|
|
||||||
|
|
||||||
for fixture_materials_data in fixture_materials_datas:
|
|
||||||
fixture_materials_list = self._get_fixture_materials_list(fixture_materials_data, fixture_materials_name,
|
|
||||||
fixture_model)
|
|
||||||
fixture_materials_code = fixture_materials_list.get('code')
|
|
||||||
# 判断同步过来的mrs刀具物料在sf夹具型号关联的夹具物料中是否存在,如果存在则修改,如果不存在则创建
|
|
||||||
if fixture_materials_code in sf_materials_model_codes:
|
|
||||||
self.search([('code', '=', fixture_materials_code)]).sudo().write(fixture_materials_list)
|
|
||||||
else:
|
|
||||||
self.sudo().create(fixture_materials_list)
|
|
||||||
|
|
||||||
def _get_sf_materials_model_codes(self, fixture_model):
|
|
||||||
fixture_materials_name = fixture_model.fixture_material_id.name
|
|
||||||
if fixture_materials_name == '零点卡盘':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.zero_chuck_ids)
|
|
||||||
elif fixture_materials_name == '零点托盘':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.zero_tray_ids)
|
|
||||||
elif fixture_materials_name == '气动夹具':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.pneumatic_fixture_ids)
|
|
||||||
elif fixture_materials_name == '虎钳夹具':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.pneumatic_fixture_ids)
|
|
||||||
elif fixture_materials_name == '磁吸夹具':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.magnet_fixture_ids)
|
|
||||||
elif fixture_materials_name == '转接板(锁板)夹具':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.adapter_board_fixture_ids)
|
|
||||||
elif fixture_materials_name == '三爪卡盘':
|
|
||||||
return self._get_sf_materials_model_code(fixture_model.scroll_chuck_ids)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _get_sf_materials_model_code(self, fixture_materials_ids):
|
|
||||||
sf_materials_model_codes = []
|
|
||||||
for fixture_materials_id in fixture_materials_ids:
|
|
||||||
sf_materials_model_codes.append(fixture_materials_id.code)
|
|
||||||
return sf_materials_model_codes
|
|
||||||
|
|
||||||
def _get_fixture_materials_list(self, fixture_materials_data, fixture_materials_name, fixture_model):
|
|
||||||
if fixture_materials_name == '零点卡盘':
|
|
||||||
return self._json_zero_chuck_param(fixture_materials_data, fixture_model)
|
|
||||||
elif fixture_materials_name == '零点托盘':
|
|
||||||
return self._json_zero_tray_param(fixture_materials_data, fixture_model)
|
|
||||||
elif fixture_materials_name == '气动夹具':
|
|
||||||
return self._json_pneumatic_fixture_param(fixture_materials_data, fixture_model)
|
|
||||||
elif fixture_materials_name == '虎钳夹具':
|
|
||||||
return self._json_jaw_vice_fixture_param(fixture_materials_data, fixture_model)
|
|
||||||
elif fixture_materials_name == '磁吸夹具':
|
|
||||||
return self._json_magnet_fixture_param(fixture_materials_data, fixture_model)
|
|
||||||
elif fixture_materials_name == '转接板(锁板)夹具':
|
|
||||||
return self._json_adapter_board_fixture_param(fixture_materials_data, fixture_model)
|
|
||||||
elif fixture_materials_name == '三爪卡盘':
|
|
||||||
return self._json_scroll_chuck_param(fixture_materials_data, fixture_model)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _json_zero_chuck_param(self, obj, fixture_model):
|
|
||||||
"""零点卡盘:将data数据转换成list数据"""
|
"""零点卡盘:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -179,12 +111,14 @@ class BasicParametersFixture(models.Model):
|
|||||||
'materials_model_id': self.env['sf.materials.model'].sudo().search(
|
'materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
||||||
'machine_tool_type_id': self.env['sf.machine_tool.type'].sudo().search(
|
'machine_tool_type_id': self.env['sf.machine_tool.type'].sudo().search(
|
||||||
[('code', '=', obj['machine_tool_type_id']), ('active', '=', True)]).id}
|
[('code', '=', obj['machine_tool_type_id']), ('active', '=', True)]).id,
|
||||||
|
'active': obj['active']}
|
||||||
|
|
||||||
def _json_zero_tray_param(self, obj, fixture_model):
|
def _json_zero_tray_param(self, obj):
|
||||||
"""零点托盘:将data数据转换成list数据"""
|
"""零点托盘:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -201,12 +135,14 @@ class BasicParametersFixture(models.Model):
|
|||||||
'carrying_capacity_max': obj['carrying_capacity_max'],
|
'carrying_capacity_max': obj['carrying_capacity_max'],
|
||||||
'materials_model_id': self.env['sf.materials.model'].sudo().search(
|
'materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
||||||
'rigidity': obj['rigidity']}
|
'rigidity': obj['rigidity'],
|
||||||
|
'active': obj['active']}
|
||||||
|
|
||||||
def _json_pneumatic_fixture_param(self, obj, fixture_model):
|
def _json_pneumatic_fixture_param(self, obj):
|
||||||
"""气动夹具:将data数据转换成list数据"""
|
"""气动夹具:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -228,12 +164,14 @@ class BasicParametersFixture(models.Model):
|
|||||||
'rigidity': obj['rigidity'],
|
'rigidity': obj['rigidity'],
|
||||||
'interface_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
'interface_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
||||||
'type_of_drive': obj['type_of_drive']}
|
'type_of_drive': obj['type_of_drive'],
|
||||||
|
'active': obj['active']}
|
||||||
|
|
||||||
def _json_jaw_vice_fixture_param(self, obj, fixture_model):
|
def _json_jaw_vice_fixture_param(self, obj):
|
||||||
"""虎钳夹具:将data数据转换成list数据"""
|
"""虎钳夹具:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -256,12 +194,14 @@ class BasicParametersFixture(models.Model):
|
|||||||
'rigidity': obj['rigidity'],
|
'rigidity': obj['rigidity'],
|
||||||
'interface_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
'interface_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
||||||
'type_of_drive': obj['type_of_drive']}
|
'type_of_drive': obj['type_of_drive'],
|
||||||
|
'active': obj['active']}
|
||||||
|
|
||||||
def _json_magnet_fixture_param(self, obj, fixture_model):
|
def _json_magnet_fixture_param(self, obj):
|
||||||
"""磁吸夹具:将data数据转换成list数据"""
|
"""磁吸夹具:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -285,12 +225,14 @@ class BasicParametersFixture(models.Model):
|
|||||||
'rigidity': obj['rigidity'],
|
'rigidity': obj['rigidity'],
|
||||||
'interface_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
'interface_materials_model_id': self.env['sf.materials.model'].sudo().search(
|
||||||
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
[('materials_no', '=', obj['materials_model_id']), ('active', '=', True)]).id,
|
||||||
'type_of_drive': obj['type_of_drive']}
|
'type_of_drive': obj['type_of_drive'],
|
||||||
|
'active': obj['active']}
|
||||||
|
|
||||||
def _json_adapter_board_fixture_param(self, obj, fixture_model):
|
def _json_adapter_board_fixture_param(self, obj):
|
||||||
"""转接板(锁板)夹具:将data数据转换成list数据"""
|
"""转接板(锁板)夹具:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -311,12 +253,14 @@ class BasicParametersFixture(models.Model):
|
|||||||
'rigidity': obj['rigidity'],
|
'rigidity': obj['rigidity'],
|
||||||
'screw_size': obj['screw_size'],
|
'screw_size': obj['screw_size'],
|
||||||
'via_hole_diameter': obj['via_hole_diameter'],
|
'via_hole_diameter': obj['via_hole_diameter'],
|
||||||
'type_of_drive': obj['type_of_drive']}
|
'type_of_drive': obj['type_of_drive'],
|
||||||
|
'active': obj['active']}
|
||||||
|
|
||||||
def _json_scroll_chuck_param(self, obj, fixture_model):
|
def _json_scroll_chuck_param(self, obj):
|
||||||
"""转接板(锁板)夹具:将data数据转换成list数据"""
|
"""转接板(锁板)夹具:将data数据转换成list数据"""
|
||||||
return {'code': obj['code'],
|
return {'code': obj['code'],
|
||||||
'fixture_model_id': fixture_model.id,
|
'fixture_model_id': self.env['sf.fixture.model'].sudo().search(
|
||||||
|
[('code', '=', obj.get('fixture_model_code'))]).id,
|
||||||
'name': obj['name'],
|
'name': obj['name'],
|
||||||
'length': obj['length'],
|
'length': obj['length'],
|
||||||
'width': obj['width'],
|
'width': obj['width'],
|
||||||
@@ -338,4 +282,5 @@ class BasicParametersFixture(models.Model):
|
|||||||
'rigidity': obj['rigidity'],
|
'rigidity': obj['rigidity'],
|
||||||
'mounting_hole_depth': obj['mounting_hole_depth'],
|
'mounting_hole_depth': obj['mounting_hole_depth'],
|
||||||
'centering_diameter': obj['centering_diameter'],
|
'centering_diameter': obj['centering_diameter'],
|
||||||
'type_of_drive': obj['type_of_drive']}
|
'type_of_drive': obj['type_of_drive'],
|
||||||
|
'active': obj['active']}
|
||||||
|
|||||||
@@ -188,3 +188,7 @@ access_sf_machine_brand_tags_group_sale_director,sf_machine_brand_tags_group_sal
|
|||||||
access_sf_machine_brand_tags_group_plan_director,sf_machine_brand_tags_group_plan_director,model_sf_machine_brand_tags,sf_base.group_plan_director,1,0,0,0
|
access_sf_machine_brand_tags_group_plan_director,sf_machine_brand_tags_group_plan_director,model_sf_machine_brand_tags,sf_base.group_plan_director,1,0,0,0
|
||||||
access_sf_machine_brand_tags_group_purchase,sf_machine_brand_tags_group_purchase,model_sf_machine_brand_tags,sf_base.group_purchase,1,0,0,0
|
access_sf_machine_brand_tags_group_purchase,sf_machine_brand_tags_group_purchase,model_sf_machine_brand_tags,sf_base.group_purchase,1,0,0,0
|
||||||
access_sf_machine_brand_tags_group_purchase_director,sf_machine_brand_tags_group_purchase_director,model_sf_machine_brand_tags,sf_base.group_purchase_director,1,0,0,0
|
access_sf_machine_brand_tags_group_purchase_director,sf_machine_brand_tags_group_purchase_director,model_sf_machine_brand_tags,sf_base.group_purchase_director,1,0,0,0
|
||||||
|
|
||||||
|
|
||||||
|
access_printer,printer,model_printer,base.group_user,1,1,1,1
|
||||||
|
access_printer_configuration,printer.configuration,model_printer_configuration,base.group_user,1,1,1,1
|
||||||
|
112
sf_base/views/Printer.xml
Normal file
112
sf_base/views/Printer.xml
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="view_printer_tree" model="ir.ui.view">
|
||||||
|
<field name="name">printer.tree</field>
|
||||||
|
<field name="model">printer</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Printer">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="ip_address"/>
|
||||||
|
<field name="port"/>
|
||||||
|
<!-- 其他字段... -->
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_printer_form" model="ir.ui.view">
|
||||||
|
<field name="name">printer.form</field>
|
||||||
|
<field name="model">printer</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Printer">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="ip_address"/>
|
||||||
|
<field name="port"/>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_printer_configuration_tree" model="ir.ui.view">
|
||||||
|
<field name="name">printer.configuration.tree</field>
|
||||||
|
<field name="model">printer.configuration</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Printer Configuration">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="printer_id"/>
|
||||||
|
<field name="model"/>
|
||||||
|
<!-- 其他字段... -->
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_printer_configuration_form" model="ir.ui.view">
|
||||||
|
<field name="name">printer.configuration.form</field>
|
||||||
|
<field name="model">printer.configuration</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Printer Configuration">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="printer_id"/>
|
||||||
|
<field name="model"/>
|
||||||
|
<!-- 其他字段... -->
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- 其他视图... -->
|
||||||
|
|
||||||
|
<record id="action_printer" model="ir.actions.act_window">
|
||||||
|
<field name="name">打印机</field>
|
||||||
|
<field name="res_model">printer</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Action to open the printer configuration list -->
|
||||||
|
<record id="action_printer_configuration" model="ir.actions.act_window">
|
||||||
|
<field name="name">打印配置</field>
|
||||||
|
<field name="res_model">printer.configuration</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Add a menu item for the printer configuration -->
|
||||||
|
<!-- <record id="menu_printer_configuration" model="ir.ui.menu"> -->
|
||||||
|
<!-- <field name="name">打印配置</field> -->
|
||||||
|
<!-- <field name="action" ref="action_printer_configuration"/> -->
|
||||||
|
<!-- <field name="parent_id" ref="base.menu_administration"/> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
|
||||||
|
<!-- <record id="menu_printer" model="ir.ui.menu"> -->
|
||||||
|
<!-- <field name="name">打印机</field> -->
|
||||||
|
<!-- <field name="action" ref="action_printer"/> -->
|
||||||
|
<!-- <field name="parent_id" ref="menu_printer"/> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="printer_main_menu"
|
||||||
|
name="打印配置"
|
||||||
|
sequence="10"
|
||||||
|
parent="base.menu_administration"/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_printer"
|
||||||
|
name="打印机"
|
||||||
|
action="action_printer"
|
||||||
|
sequence="1"
|
||||||
|
parent="printer_main_menu"/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_printer_configuration"
|
||||||
|
name="打印配置"
|
||||||
|
action="action_printer_configuration"
|
||||||
|
sequence="2"
|
||||||
|
parent="printer_main_menu"/>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -148,7 +148,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
MTcode = fields.Char("机台编码")
|
MTcode = fields.Char("机台编码")
|
||||||
created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
|
created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user)
|
||||||
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'),
|
||||||
('检测设备', '检测设备')], compute='_compute_category_id')
|
('检测设备', '检测设备'), ('其他', '其他')], compute='_compute_category_id')
|
||||||
|
|
||||||
@api.depends('category_id')
|
@api.depends('category_id')
|
||||||
def _compute_category_id(self):
|
def _compute_category_id(self):
|
||||||
|
|||||||
@@ -219,7 +219,8 @@ class StockRule(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class ProductionLot(models.Model):
|
class ProductionLot(models.Model):
|
||||||
_inherit = 'stock.lot'
|
_name = 'stock.lot'
|
||||||
|
_inherit = ['stock.lot', 'printing.utils']
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def generate_lot_names1(self, display_name, first_lot, count):
|
def generate_lot_names1(self, display_name, first_lot, count):
|
||||||
@@ -263,7 +264,7 @@ class ProductionLot(models.Model):
|
|||||||
if not last_serial:
|
if not last_serial:
|
||||||
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
|
||||||
else:
|
else:
|
||||||
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1)
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 2)
|
||||||
else:
|
else:
|
||||||
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
|
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
|
||||||
|
|
||||||
@@ -307,36 +308,53 @@ class ProductionLot(models.Model):
|
|||||||
|
|
||||||
record.qr_code_image = encoded_image
|
record.qr_code_image = encoded_image
|
||||||
|
|
||||||
def print_qr_code(self):
|
def print_single_method(self):
|
||||||
self.ensure_one() # 确保这个方法只为一个记录调用
|
|
||||||
# if not self.lot_id:
|
self.ensure_one()
|
||||||
# raise UserError("没有找到序列号。")
|
|
||||||
# 假设_lot_qr_code方法已经生成了二维码并保存在字段中
|
|
||||||
qr_code_data = self.qr_code_image
|
qr_code_data = self.qr_code_image
|
||||||
if not qr_code_data:
|
if not qr_code_data:
|
||||||
raise UserError("没有找到二维码数据。")
|
raise UserError("没有找到二维码数据。")
|
||||||
|
lot_name = self.name
|
||||||
|
# host = "192.168.50.110" # 可以根据实际情况修改
|
||||||
|
# port = 9100 # 可以根据实际情况修改
|
||||||
|
|
||||||
# 生成下载链接或直接触发下载
|
# 获取默认打印机配置
|
||||||
# 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
|
printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
|
||||||
attachment = self.env['ir.attachment'].sudo().create({
|
if not printer_config:
|
||||||
'datas': self.qr_code_image,
|
raise UserError('请先配置打印机')
|
||||||
'type': 'binary',
|
host = printer_config.printer_id.ip_address
|
||||||
'description': '二维码图片',
|
port = printer_config.printer_id.port
|
||||||
'name': self.name + '.png',
|
self.print_qr_code(lot_name, host, port)
|
||||||
# 'res_id': invoice.id,
|
|
||||||
# 'res_model': 'stock.picking',
|
# self.ensure_one() # 确保这个方法只为一个记录调用
|
||||||
'public': True,
|
# # if not self.lot_id:
|
||||||
'mimetype': 'application/x-png',
|
# # raise UserError("没有找到序列号。")
|
||||||
# 'model_name': 'stock.picking',
|
# # 假设_lot_qr_code方法已经生成了二维码并保存在字段中
|
||||||
})
|
# qr_code_data = self.qr_code_image
|
||||||
# 返回附件的下载链接
|
# if not qr_code_data:
|
||||||
download_url = '/web/content/%s?download=true' % attachment.id
|
# raise UserError("没有找到二维码数据。")
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
#
|
||||||
return {
|
# # 生成下载链接或直接触发下载
|
||||||
'type': 'ir.actions.act_url',
|
# # 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
|
||||||
'url': str(base_url) + download_url,
|
# attachment = self.env['ir.attachment'].sudo().create({
|
||||||
'target': 'self',
|
# 'datas': self.qr_code_image,
|
||||||
}
|
# 'type': 'binary',
|
||||||
|
# 'description': '二维码图片',
|
||||||
|
# 'name': self.name + '.png',
|
||||||
|
# # 'res_id': invoice.id,
|
||||||
|
# # 'res_model': 'stock.picking',
|
||||||
|
# 'public': True,
|
||||||
|
# 'mimetype': 'application/x-png',
|
||||||
|
# # 'model_name': 'stock.picking',
|
||||||
|
# })
|
||||||
|
# # 返回附件的下载链接
|
||||||
|
# download_url = '/web/content/%s?download=true' % attachment.id
|
||||||
|
# base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
# return {
|
||||||
|
# 'type': 'ir.actions.act_url',
|
||||||
|
# 'url': str(base_url) + download_url,
|
||||||
|
# 'target': 'self',
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
class StockPicking(models.Model):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet" position="before">
|
<xpath expr="//sheet" position="before">
|
||||||
<header>
|
<header>
|
||||||
<button string="打印二维码" name="print_qr_code" type="object" class="btn-primary"/>
|
<button string="打印二维码" name="print_single_method" type="object" class="btn-primary"/>
|
||||||
</header>
|
</header>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
_logger.info("同步联装类型完成")
|
_logger.info("同步联装类型完成")
|
||||||
self.env['sf.fixture.model'].sync_all_fixture_model()
|
self.env['sf.fixture.model'].sync_all_fixture_model()
|
||||||
_logger.info("同步夹具型号完成")
|
_logger.info("同步夹具型号完成")
|
||||||
|
self.env['sf.fixture.materials.basic.parameters'].sync_all_fixture_materials_basic_parameters()
|
||||||
|
_logger.info("同步夹具型号基本信息完成")
|
||||||
self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type()
|
self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type()
|
||||||
_logger.info("同步夹具型号类型完成")
|
_logger.info("同步夹具型号类型完成")
|
||||||
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
|
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ class MrStaticResourceDataSync(models.Model):
|
|||||||
logging.info("联装类型已每日同步成功")
|
logging.info("联装类型已每日同步成功")
|
||||||
self.env['sf.fixture.model'].sync_fixture_model_yesterday()
|
self.env['sf.fixture.model'].sync_fixture_model_yesterday()
|
||||||
logging.info("夹具型号已每日同步成功")
|
logging.info("夹具型号已每日同步成功")
|
||||||
|
self.env['sf.fixture.materials.basic.parameters'].sync_fixture_materials_basic_parameters_yesterday()
|
||||||
|
logging.info("夹具型号基本参数已每日同步成功")
|
||||||
|
self.env['sf.functional.fixture.type'].sync_fixture_materials_basic_parameters_yesterday()
|
||||||
|
logging.info("夹具型号基本参数已每日同步成功")
|
||||||
self.env['sf.functional.fixture.type'].sync_functional_fixture_type_yesterday()
|
self.env['sf.functional.fixture.type'].sync_functional_fixture_type_yesterday()
|
||||||
logging.info("功能夹具类型已每日同步成功")
|
logging.info("功能夹具类型已每日同步成功")
|
||||||
self.env['sf.cutting.tool.material'].sync_cutting_tool_material_yesterday()
|
self.env['sf.cutting.tool.material'].sync_cutting_tool_material_yesterday()
|
||||||
@@ -1476,7 +1480,6 @@ class SyncFixtureModel(models.Model):
|
|||||||
for item in result['fixture_model_yesterday_list']:
|
for item in result['fixture_model_yesterday_list']:
|
||||||
if item:
|
if item:
|
||||||
fixture_model = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
|
fixture_model = self.search([("code", '=', item['code']), ('active', 'in', [True, False])])
|
||||||
fixture_materials = self.env['sf.fixture.materials.basic.parameters']
|
|
||||||
val = {
|
val = {
|
||||||
"name": item['name'],
|
"name": item['name'],
|
||||||
"code": item['code'],
|
"code": item['code'],
|
||||||
@@ -1490,48 +1493,10 @@ class SyncFixtureModel(models.Model):
|
|||||||
"active": item['active'],
|
"active": item['active'],
|
||||||
}
|
}
|
||||||
if not fixture_model:
|
if not fixture_model:
|
||||||
fixture_model = self.create(val)
|
self.create(val)
|
||||||
fixture_material_name = fixture_model.fixture_material_id.name
|
|
||||||
if item['zero_chuck_ids'] and fixture_material_name == '零点卡盘':
|
|
||||||
fixture_materials.create_fixture_materials(item['zero_chuck_ids'], fixture_model)
|
|
||||||
elif item['zero_tray_ids'] and fixture_material_name == '零点托盘':
|
|
||||||
fixture_materials.create_fixture_materials(item['zero_tray_ids'], fixture_model)
|
|
||||||
elif item['pneumatic_fixture_ids'] and fixture_material_name == '气动夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['pneumatic_fixture_ids'], fixture_model)
|
|
||||||
elif item['jaw_vice_fixture_ids'] and fixture_material_name == '虎钳夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['jaw_vice_fixture_ids'], fixture_model)
|
|
||||||
elif item['magnet_fixture_ids'] and fixture_material_name == '磁吸夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['magnet_fixture_ids'], fixture_model)
|
|
||||||
elif item['adapter_board_fixture_ids'] and fixture_material_name == '转接板(锁板)夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['adapter_board_fixture_ids'],
|
|
||||||
fixture_model)
|
|
||||||
elif item['scroll_chuck_ids'] and fixture_material_name == '三爪卡盘':
|
|
||||||
fixture_materials.create_fixture_materials(item['scroll_chuck_ids'], fixture_model)
|
|
||||||
else:
|
else:
|
||||||
fixture_model.write(val)
|
fixture_model.write(val)
|
||||||
fixture_material_name = fixture_model.fixture_material_id.name
|
|
||||||
if item['zero_chuck_ids'] and fixture_material_name == '零点卡盘':
|
|
||||||
fixture_materials.write_fixture_materials(item['zero_chuck_ids'], fixture_material_name)
|
|
||||||
elif item['zero_tray_ids'] and fixture_material_name == '零点托盘':
|
|
||||||
fixture_materials.write_fixture_materials(item['zero_tray_ids'], fixture_material_name)
|
|
||||||
elif item['pneumatic_fixture_ids'] and fixture_material_name == '气动夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['pneumatic_fixture_ids'],
|
|
||||||
fixture_material_name)
|
|
||||||
elif item['jaw_vice_fixture_ids'] and fixture_material_name == '虎钳夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['jaw_vice_fixture_ids'],
|
|
||||||
fixture_material_name)
|
|
||||||
elif item['magnet_fixture_ids'] and fixture_material_name == '磁吸夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['magnet_fixture_ids'],
|
|
||||||
fixture_material_name)
|
|
||||||
elif item['adapter_board_fixture_ids'] and fixture_material_name == '转接板(锁板)夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['adapter_board_fixture_ids'],
|
|
||||||
fixture_material_name)
|
|
||||||
elif item['scroll_chuck_ids'] and fixture_material_name == '三爪卡盘':
|
|
||||||
fixture_materials.write_fixture_materials(item['scroll_chuck_ids'],
|
|
||||||
fixture_material_name)
|
|
||||||
else:
|
|
||||||
self.env['sf.fixture.materials.basic.parameters'].sudo().search(
|
|
||||||
[('fixture_model_id', '=', fixture_model.id)]).unlink()
|
|
||||||
else:
|
else:
|
||||||
raise ValidationError("夹具型号认证未通过")
|
raise ValidationError("夹具型号认证未通过")
|
||||||
|
|
||||||
@@ -1549,7 +1514,6 @@ class SyncFixtureModel(models.Model):
|
|||||||
for item in result['fixture_model_all_list']:
|
for item in result['fixture_model_all_list']:
|
||||||
if item:
|
if item:
|
||||||
fixture_model = self.search([('code', '=', item['code']), ('active', 'in', [True, False])])
|
fixture_model = self.search([('code', '=', item['code']), ('active', 'in', [True, False])])
|
||||||
fixture_materials = self.env['sf.fixture.materials.basic.parameters']
|
|
||||||
val = {
|
val = {
|
||||||
"name": item['name'],
|
"name": item['name'],
|
||||||
"code": item['code'],
|
"code": item['code'],
|
||||||
@@ -1563,48 +1527,85 @@ class SyncFixtureModel(models.Model):
|
|||||||
"active": item['active'],
|
"active": item['active'],
|
||||||
}
|
}
|
||||||
if not fixture_model:
|
if not fixture_model:
|
||||||
fixture_model = self.create(val)
|
self.create(val)
|
||||||
fixture_material_name = fixture_model.fixture_material_id.name
|
|
||||||
if item['zero_chuck_ids'] and fixture_material_name == '零点卡盘':
|
|
||||||
fixture_materials.create_fixture_materials(item['zero_chuck_ids'], fixture_model)
|
|
||||||
elif item['zero_tray_ids'] and fixture_material_name == '零点托盘':
|
|
||||||
fixture_materials.create_fixture_materials(item['zero_tray_ids'], fixture_model)
|
|
||||||
elif item['pneumatic_fixture_ids'] and fixture_material_name == '气动夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['pneumatic_fixture_ids'], fixture_model)
|
|
||||||
elif item['jaw_vice_fixture_ids'] and fixture_material_name == '虎钳夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['jaw_vice_fixture_ids'], fixture_model)
|
|
||||||
elif item['magnet_fixture_ids'] and fixture_material_name == '磁吸夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['magnet_fixture_ids'], fixture_model)
|
|
||||||
elif item['adapter_board_fixture_ids'] and fixture_material_name == '转接板(锁板)夹具':
|
|
||||||
fixture_materials.create_fixture_materials(item['adapter_board_fixture_ids'],
|
|
||||||
fixture_model)
|
|
||||||
elif item['scroll_chuck_ids'] and fixture_material_name == '三爪卡盘':
|
|
||||||
fixture_materials.create_fixture_materials(item['scroll_chuck_ids'], fixture_model)
|
|
||||||
else:
|
else:
|
||||||
fixture_model.write(val)
|
fixture_model.write(val)
|
||||||
fixture_material_name = fixture_model.fixture_material_id.name
|
|
||||||
if item['zero_chuck_ids'] and fixture_material_name == '零点卡盘':
|
|
||||||
fixture_materials.write_fixture_materials(item['zero_chuck_ids'], fixture_model)
|
|
||||||
elif item['zero_tray_ids'] and fixture_material_name == '零点托盘':
|
|
||||||
fixture_materials.write_fixture_materials(item['zero_tray_ids'], fixture_model)
|
|
||||||
elif item['pneumatic_fixture_ids'] and fixture_material_name == '气动夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['pneumatic_fixture_ids'], fixture_model)
|
|
||||||
elif item['jaw_vice_fixture_ids'] and fixture_material_name == '虎钳夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['jaw_vice_fixture_ids'], fixture_model)
|
|
||||||
elif item['magnet_fixture_ids'] and fixture_material_name == '磁吸夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['magnet_fixture_ids'], fixture_model)
|
|
||||||
elif item['adapter_board_fixture_ids'] and fixture_material_name == '转接板(锁板)夹具':
|
|
||||||
fixture_materials.write_fixture_materials(item['adapter_board_fixture_ids'],
|
|
||||||
fixture_model)
|
|
||||||
elif item['scroll_chuck_ids'] and fixture_material_name == '三爪卡盘':
|
|
||||||
fixture_materials.write_fixture_materials(item['scroll_chuck_ids'], fixture_model)
|
|
||||||
else:
|
|
||||||
self.env['sf.fixture.materials.basic.parameters'].sudo().search(
|
|
||||||
[('fixture_model_id', '=', fixture_model.id)]).unlink()
|
|
||||||
else:
|
else:
|
||||||
raise ValidationError("夹具型号认证未通过")
|
raise ValidationError("夹具型号认证未通过")
|
||||||
|
|
||||||
|
|
||||||
|
class SyncfixtureMaterialsBasicParameters(models.Model):
|
||||||
|
_inherit = 'sf.fixture.materials.basic.parameters'
|
||||||
|
_description = '同步夹具型号基本参数列表'
|
||||||
|
|
||||||
|
url = '/api/fixture_parameters/list'
|
||||||
|
|
||||||
|
# 定时同步夹具型号基本信息
|
||||||
|
def sync_fixture_materials_basic_parameters_yesterday(self):
|
||||||
|
config = self.env['res.config.settings'].get_values()
|
||||||
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
|
strUrl = config['sf_url'] + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
if result.get('fixture_parameters_yesterday_list'):
|
||||||
|
all_list = result.get('fixture_parameters_yesterday_list')
|
||||||
|
if all_list.get('zero_chuck_all_list'):
|
||||||
|
self._write_or_create(all_list.get('zero_chuck_yesterday_list'), '零点卡盘')
|
||||||
|
if all_list.get('zero_tray_all_list'):
|
||||||
|
self._write_or_create(all_list.get('zero_tray_yesterday_list'), '零点托盘')
|
||||||
|
if all_list.get('pneumatic_fixture_all_list'):
|
||||||
|
self._write_or_create(all_list.get('pneumatic_fixture_yesterday_list'), '气动夹具')
|
||||||
|
if all_list.get('jaw_vice_all_list'):
|
||||||
|
self._write_or_create(all_list.get('jaw_vice_yesterday_list'), '虎钳夹具')
|
||||||
|
if all_list.get('magnet_fixture_all_list'):
|
||||||
|
self._write_or_create(all_list.get('magnet_fixture_yesterday_list'), '磁吸夹具')
|
||||||
|
if all_list.get('adapter_board_all_list'):
|
||||||
|
self._write_or_create(all_list.get('adapter_board_yesterday_list'), '转接板(锁板)夹具')
|
||||||
|
if all_list.get('scroll_chuck_all_list'):
|
||||||
|
self._write_or_create(all_list.get('scroll_chuck_yesterday_list'), '三爪卡盘')
|
||||||
|
else:
|
||||||
|
raise ValidationError("夹具型号基本参数认证未通过")
|
||||||
|
|
||||||
|
# 定时同步所有夹具型号基本信息
|
||||||
|
def sync_all_fixture_materials_basic_parameters(self):
|
||||||
|
config = self.env['res.config.settings'].get_values()
|
||||||
|
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
|
strUrl = config['sf_url'] + self.url
|
||||||
|
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
if result.get('fixture_parameters_all_list'):
|
||||||
|
all_list = result.get('fixture_parameters_all_list')
|
||||||
|
if all_list.get('zero_chuck_all_list'):
|
||||||
|
self._write_or_create(all_list.get('zero_chuck_all_list'), '零点卡盘')
|
||||||
|
if all_list.get('zero_tray_all_list'):
|
||||||
|
self._write_or_create(all_list.get('zero_tray_all_list'), '零点托盘')
|
||||||
|
if all_list.get('pneumatic_fixture_all_list'):
|
||||||
|
self._write_or_create(all_list.get('pneumatic_fixture_all_list'), '气动夹具')
|
||||||
|
if all_list.get('jaw_vice_all_list'):
|
||||||
|
self._write_or_create(all_list.get('jaw_vice_all_list'), '虎钳夹具')
|
||||||
|
if all_list.get('magnet_fixture_all_list'):
|
||||||
|
self._write_or_create(all_list.get('magnet_fixture_all_list'), '磁吸夹具')
|
||||||
|
if all_list.get('adapter_board_all_list'):
|
||||||
|
self._write_or_create(all_list.get('adapter_board_all_list'), '转接板(锁板)夹具')
|
||||||
|
if all_list.get('scroll_chuck_all_list'):
|
||||||
|
self._write_or_create(all_list.get('scroll_chuck_all_list'), '三爪卡盘')
|
||||||
|
else:
|
||||||
|
raise ValidationError("夹具型号基本参数认证未通过")
|
||||||
|
|
||||||
|
def _write_or_create(self, fixture_parameters_list, material_name):
|
||||||
|
for item in fixture_parameters_list:
|
||||||
|
if item:
|
||||||
|
basic_parameters = self.search([('code', '=', item.get('code')), ('active', 'in', [True, False])])
|
||||||
|
if not basic_parameters:
|
||||||
|
self.create(self._get_basic_parameters_list(item, material_name))
|
||||||
|
else:
|
||||||
|
basic_parameters.write(self._get_basic_parameters_list(item, material_name))
|
||||||
|
|
||||||
|
|
||||||
class SyncFunctionalFixtureType(models.Model):
|
class SyncFunctionalFixtureType(models.Model):
|
||||||
_inherit = 'sf.functional.fixture.type'
|
_inherit = 'sf.functional.fixture.type'
|
||||||
_description = '同步功能夹具类型列表'
|
_description = '同步功能夹具类型列表'
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ class QualityCheck(models.Model):
|
|||||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
# headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
||||||
crea_url = "https://x24467i973.zicp.fun/AutoDeviceApi/PartSpecProc"
|
crea_url = "https://x24467i973.zicp.fun/AutoDeviceApi/PartSpecProc"
|
||||||
val = ['0037835872']
|
origin = self.picking_id.origin
|
||||||
|
production_id = self.env['mrp.production'].sudo().search([('name', '=', origin)])
|
||||||
|
rfid = '' if not production_id.workorder_ids else production_id.workorder_ids[-1].rfid_code or ''
|
||||||
|
val = [rfid]
|
||||||
r = requests.post(crea_url, json=val, headers=headers)
|
r = requests.post(crea_url, json=val, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
logging.info('_register_quality_check:%s' % ret)
|
logging.info('_register_quality_check:%s' % ret)
|
||||||
@@ -33,4 +36,5 @@ class QualityCheck(models.Model):
|
|||||||
'quality_state': 'fail',
|
'quality_state': 'fail',
|
||||||
'user_id': self.env.user.id,
|
'user_id': self.env.user.id,
|
||||||
'control_date': datetime.now()})
|
'control_date': datetime.now()})
|
||||||
|
if self.picking_id and 'WH/MO/' in self.picking_id.origin:
|
||||||
self._register_quality_check()
|
self._register_quality_check()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
'views/sf_maintenance_equipment.xml',
|
'views/sf_maintenance_equipment.xml',
|
||||||
'views/menu_view.xml',
|
'views/menu_view.xml',
|
||||||
'views/tool_material_search.xml',
|
'views/tool_material_search.xml',
|
||||||
|
'views/fixture_material_search_views.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,4 +3,6 @@ from . import tool_material_search
|
|||||||
from . import maintenance_equipment
|
from . import maintenance_equipment
|
||||||
from . import mrp_workorder
|
from . import mrp_workorder
|
||||||
from . import functional_tool_enroll
|
from . import functional_tool_enroll
|
||||||
|
from . import fixture_material_search
|
||||||
|
from . import fixture_enroll
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
_description = '功能刀具列表'
|
_description = '功能刀具列表'
|
||||||
|
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
|
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
|
||||||
code = fields.Char('编码', related='functional_tool_name_id.code')
|
code = fields.Char('编码')
|
||||||
rfid = fields.Char('rfid', readonly=True)
|
rfid = fields.Char('Rfid', readonly=True)
|
||||||
name = fields.Char('名称')
|
name = fields.Char('名称')
|
||||||
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True)
|
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称', readonly=True)
|
||||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True)
|
||||||
@@ -222,7 +222,7 @@ class FunctionalToolWarning(models.Model):
|
|||||||
_description = '功能刀具预警'
|
_description = '功能刀具预警'
|
||||||
|
|
||||||
code = fields.Char('编码', related='functional_tool_name_id.code')
|
code = fields.Char('编码', related='functional_tool_name_id.code')
|
||||||
rfid = fields.Char('rfid', related='functional_tool_name_id.rfid')
|
rfid = fields.Char('Rfid', related='functional_tool_name_id.rfid')
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
|
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id')
|
||||||
name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name')
|
name = fields.Char('名称', invisible=True, readonly=True, related='functional_tool_name_id.name')
|
||||||
# 机床信息
|
# 机床信息
|
||||||
@@ -296,7 +296,7 @@ class StockMoveLine(models.Model):
|
|||||||
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
|
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
|
||||||
install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now())
|
install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now())
|
||||||
code = fields.Char('编码')
|
code = fields.Char('编码')
|
||||||
rfid = fields.Char('rfid')
|
rfid = fields.Char('Rfid')
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
|
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组')
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -502,7 +502,7 @@ class MachineTableToolChangingApply(models.Model):
|
|||||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True,
|
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', store=True,
|
||||||
domain=[('product_id.name', '=', '功能刀具')],
|
domain=[('product_id.name', '=', '功能刀具')],
|
||||||
related='functional_tool_name_id.barcode_id')
|
related='functional_tool_name_id.barcode_id')
|
||||||
rfid = fields.Char('rfid', related='functional_tool_name_id.rfid')
|
rfid = fields.Char('Rfid', related='functional_tool_name_id.rfid')
|
||||||
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', domain=[('assemble_status', '=', '1')],
|
functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', domain=[('assemble_status', '=', '1')],
|
||||||
string='功能刀具名称')
|
string='功能刀具名称')
|
||||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
|
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
|
||||||
@@ -828,7 +828,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
obj.name = obj.after_assembly_functional_tool_name
|
obj.name = obj.after_assembly_functional_tool_name
|
||||||
|
|
||||||
code = fields.Char('功能刀具编码', readonly=True)
|
code = fields.Char('功能刀具编码', readonly=True)
|
||||||
rfid = fields.Char('rfid', readonly=True)
|
rfid = fields.Char('Rfid', readonly=True)
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
|
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
|
||||||
name = fields.Char(string='名称', readonly=True, compute='_compute_name')
|
name = fields.Char(string='名称', readonly=True, compute='_compute_name')
|
||||||
assembly_order_code = fields.Char(string='组装单编码', readonly=True)
|
assembly_order_code = fields.Char(string='组装单编码', readonly=True)
|
||||||
|
|||||||
82
sf_tool_management/models/fixture_enroll.py
Normal file
82
sf_tool_management/models/fixture_enroll.py
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import json
|
||||||
|
import base64
|
||||||
|
import requests
|
||||||
|
from odoo import models, api
|
||||||
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
class StockLot(models.Model):
|
||||||
|
_inherit = 'stock.lot'
|
||||||
|
_description = '夹具物料序列号注册'
|
||||||
|
|
||||||
|
def enroll_fixture_material_stock(self):
|
||||||
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
|
token = sf_sync_config['token']
|
||||||
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
|
str_url = sf_sync_config['sf_url'] + "/api/fixture_material_stock/create"
|
||||||
|
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
||||||
|
fixture_material_stock_list = []
|
||||||
|
if objs_all:
|
||||||
|
for item in objs_all:
|
||||||
|
val = {
|
||||||
|
'name': item.name,
|
||||||
|
'tool_material_status': item.tool_material_status,
|
||||||
|
'location': [] if not item.quant_ids else item.quant_ids[-1].location_id.name,
|
||||||
|
'fixture_material_search_id': item.fixture_material_search_id.id,
|
||||||
|
}
|
||||||
|
fixture_material_stock_list.append(val)
|
||||||
|
kw = json.dumps(fixture_material_stock_list, ensure_ascii=False)
|
||||||
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
|
ret = r.json()
|
||||||
|
if ret.get('code') == 200:
|
||||||
|
return '夹具物料序列号注册成功'
|
||||||
|
else:
|
||||||
|
raise UserError("没有注册夹具物料序列号信息")
|
||||||
|
|
||||||
|
|
||||||
|
class FixtureMaterialSearch(models.Model):
|
||||||
|
_inherit = 'sf.fixture.material.search'
|
||||||
|
_description = '夹具物料搜索注册'
|
||||||
|
|
||||||
|
crea_url = "/api/fixture_material/create"
|
||||||
|
|
||||||
|
def enroll_fixture_material(self):
|
||||||
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
|
token = sf_sync_config['token']
|
||||||
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
||||||
|
objs_all = self.search([('id', '=', self.id)])
|
||||||
|
fixture_material_list = []
|
||||||
|
if objs_all:
|
||||||
|
for obj in objs_all:
|
||||||
|
val = {
|
||||||
|
'name': obj.name,
|
||||||
|
'id': obj.id,
|
||||||
|
'fixture_material_code': obj.fixture_material_id.code,
|
||||||
|
'fixture_model_code': obj.fixture_model_id.code,
|
||||||
|
'specification_name': obj.specification_fixture_id.name,
|
||||||
|
'image': '' if not obj.image else base64.b64encode(obj.image).decode('utf-8'),
|
||||||
|
'number': obj.number,
|
||||||
|
'usable_num': obj.usable_num,
|
||||||
|
'have_been_used_num': obj.have_been_used_num,
|
||||||
|
'scrap_num': obj.scrap_num
|
||||||
|
}
|
||||||
|
fixture_material_list.append(val)
|
||||||
|
kw = json.dumps(fixture_material_list, ensure_ascii=False)
|
||||||
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
|
ret = r.json()
|
||||||
|
if ret.get('code') == 200:
|
||||||
|
return '夹具物料注册成功'
|
||||||
|
else:
|
||||||
|
raise UserError("没有注册夹具物料信息")
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
records = super(FixtureMaterialSearch, self).create(vals_list)
|
||||||
|
for record in records:
|
||||||
|
if record:
|
||||||
|
record.enroll_fixture_material()
|
||||||
|
return records
|
||||||
55
sf_tool_management/models/fixture_material_search.py
Normal file
55
sf_tool_management/models/fixture_material_search.py
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
from odoo import models, fields, api, SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
|
class FixtureMaterialSearch(models.Model):
|
||||||
|
_name = 'sf.fixture.material.search'
|
||||||
|
_description = '夹具物料搜索'
|
||||||
|
|
||||||
|
product_id = fields.Many2one('product.product', string='夹具物料产品')
|
||||||
|
|
||||||
|
name = fields.Char('名称', related='product_id.name')
|
||||||
|
code = fields.Char('编码')
|
||||||
|
fixture_material_id = fields.Many2one('sf.fixture.material', '夹具物料',
|
||||||
|
related='product_id.fixture_material_id',
|
||||||
|
store=True,
|
||||||
|
group_expand='_read_group_fixture_material_id')
|
||||||
|
fixture_material_name = fields.Char('物料名称', related='product_id.fixture_material_id.name')
|
||||||
|
fixture_model_id = fields.Many2one('sf.fixture.model', '夹具型号',
|
||||||
|
related='product_id.fixture_model_id')
|
||||||
|
specification_fixture_id = fields.Many2one('sf.fixture.materials.basic.parameters', '规格',
|
||||||
|
related='product_id.specification_fixture_id')
|
||||||
|
image = fields.Binary('图片', related='product_id.image_1920')
|
||||||
|
number = fields.Integer('总数量', compute='_compute_number')
|
||||||
|
usable_num = fields.Integer('可用数量', compute='_compute_number')
|
||||||
|
have_been_used_num = fields.Integer('在用数量', compute='_compute_number')
|
||||||
|
scrap_num = fields.Integer('报废数量', compute='_compute_number')
|
||||||
|
|
||||||
|
barcode_ids = fields.One2many('stock.lot', 'fixture_material_search_id', string='序列号', readonly=True)
|
||||||
|
|
||||||
|
@api.depends('barcode_ids')
|
||||||
|
def _compute_number(self):
|
||||||
|
for record in self:
|
||||||
|
usable_num = 0
|
||||||
|
have_been_used_num = 0
|
||||||
|
scrap_num = 0
|
||||||
|
if record.barcode_ids:
|
||||||
|
record.number = len(record.barcode_ids)
|
||||||
|
for barcode_id in record.barcode_ids:
|
||||||
|
if barcode_id.quant_ids:
|
||||||
|
if barcode_id.quant_ids[-1].location_id.name not in '夹具房':
|
||||||
|
have_been_used_num = have_been_used_num + 1
|
||||||
|
else:
|
||||||
|
usable_num = usable_num + 1
|
||||||
|
record.usable_num = usable_num
|
||||||
|
record.have_been_used_num = have_been_used_num
|
||||||
|
record.scrap_num = scrap_num
|
||||||
|
else:
|
||||||
|
record.number = 0
|
||||||
|
record.usable_num = 0
|
||||||
|
record.have_been_used_num = 0
|
||||||
|
record.scrap_num = 0
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _read_group_fixture_material_id(self, categories, domain, order):
|
||||||
|
fixture_material_id = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
||||||
|
return categories.browse(fixture_material_id)
|
||||||
@@ -34,14 +34,12 @@ class StockLot(models.Model):
|
|||||||
_inherit = 'stock.lot'
|
_inherit = 'stock.lot'
|
||||||
_description = '刀具物料序列号注册'
|
_description = '刀具物料序列号注册'
|
||||||
|
|
||||||
crea_url = "/api/tool_material_stock/create"
|
|
||||||
|
|
||||||
def enroll_tool_material_stock(self):
|
def enroll_tool_material_stock(self):
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
str_url = sf_sync_config['sf_url'] + self.crea_url
|
str_url = sf_sync_config['sf_url'] + "/api/tool_material_stock/create"
|
||||||
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
objs_all = self.env['stock.lot'].search([('id', '=', self.id)])
|
||||||
tool_material_stock_list = []
|
tool_material_stock_list = []
|
||||||
if objs_all:
|
if objs_all:
|
||||||
@@ -61,15 +59,6 @@ class StockLot(models.Model):
|
|||||||
else:
|
else:
|
||||||
raise UserError("没有注册刀具物料序列号信息")
|
raise UserError("没有注册刀具物料序列号信息")
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
records = super(StockLot, self).create(vals_list)
|
|
||||||
for record in records:
|
|
||||||
if record.product_id.categ_id.name == '刀具':
|
|
||||||
record.tool_material_status = '可用'
|
|
||||||
record.enroll_tool_material_stock()
|
|
||||||
return records
|
|
||||||
|
|
||||||
|
|
||||||
class ToolMaterial(models.Model):
|
class ToolMaterial(models.Model):
|
||||||
_inherit = 'sf.tool.material.search'
|
_inherit = 'sf.tool.material.search'
|
||||||
@@ -87,10 +76,6 @@ class ToolMaterial(models.Model):
|
|||||||
tool_material_list = []
|
tool_material_list = []
|
||||||
if objs_all:
|
if objs_all:
|
||||||
for item in objs_all:
|
for item in objs_all:
|
||||||
barcode_names = []
|
|
||||||
for barcode_id in item.barcode_ids:
|
|
||||||
if barcode_id.name:
|
|
||||||
barcode_names.append(barcode_id.name)
|
|
||||||
val = {
|
val = {
|
||||||
'name': item.name,
|
'name': item.name,
|
||||||
'id': item.id,
|
'id': item.id,
|
||||||
@@ -101,9 +86,7 @@ class ToolMaterial(models.Model):
|
|||||||
'number': item.number,
|
'number': item.number,
|
||||||
'usable_num': item.usable_num,
|
'usable_num': item.usable_num,
|
||||||
'have_been_used_num': item.have_been_used_num,
|
'have_been_used_num': item.have_been_used_num,
|
||||||
'scrap_num': item.scrap_num,
|
'scrap_num': item.scrap_num
|
||||||
'barcode_names': str(barcode_names),
|
|
||||||
'active': item.active
|
|
||||||
}
|
}
|
||||||
tool_material_list.append(val)
|
tool_material_list.append(val)
|
||||||
kw = json.dumps(tool_material_list, ensure_ascii=False)
|
kw = json.dumps(tool_material_list, ensure_ascii=False)
|
||||||
|
|||||||
@@ -97,25 +97,29 @@ class StockLot(models.Model):
|
|||||||
_inherit = 'stock.lot'
|
_inherit = 'stock.lot'
|
||||||
|
|
||||||
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
|
tool_material_search_id = fields.Many2one('sf.tool.material.search', string='刀具物料搜索')
|
||||||
tool_material_status = fields.Selection([('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态',
|
fixture_material_search_id = fields.Many2one('sf.fixture.material.search', string='夹具物料搜索')
|
||||||
|
tool_material_status = fields.Selection(
|
||||||
|
[('未入库', '未入库'), ('可用', '可用'), ('在用', '在用'), ('报废', '报废')], string='状态',
|
||||||
compute='_compute_tool_material_status', store=True)
|
compute='_compute_tool_material_status', store=True)
|
||||||
|
|
||||||
@api.depends('quant_ids')
|
@api.depends('quant_ids')
|
||||||
def _compute_tool_material_status(self):
|
def _compute_tool_material_status(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record:
|
if record:
|
||||||
|
if record.product_id.categ_id.name in ['刀具', '夹具']:
|
||||||
if record.quant_ids:
|
if record.quant_ids:
|
||||||
if record.quant_ids[-1].location_id.name == '刀具组装位置':
|
if record.quant_ids[-1].location_id.name in ['刀具房', '夹具房']:
|
||||||
|
record.tool_material_status = '可用'
|
||||||
|
elif record.quant_ids[-1].location_id.name == '刀具组装位置':
|
||||||
record.tool_material_status = '在用'
|
record.tool_material_status = '在用'
|
||||||
else:
|
else:
|
||||||
record.tool_material_status = '可用'
|
record.tool_material_status = '未入库'
|
||||||
|
if record.tool_material_search_id:
|
||||||
@api.onchange('tool_material_status')
|
|
||||||
def _onchange_tool_material_status(self):
|
|
||||||
for obj in self:
|
|
||||||
if obj:
|
|
||||||
# 注册刀具物料状态到cloud平台
|
# 注册刀具物料状态到cloud平台
|
||||||
obj.enroll_tool_material_stock()
|
record.enroll_tool_material_stock()
|
||||||
|
elif record.fixture_material_search_id:
|
||||||
|
# 注册夹具物料状态到cloud平台
|
||||||
|
record.enroll_fixture_material_stock()
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||||
@@ -146,7 +150,14 @@ class StockLot(models.Model):
|
|||||||
tool_material_search = self.env['sf.tool.material.search'].sudo().search(
|
tool_material_search = self.env['sf.tool.material.search'].sudo().search(
|
||||||
[('id', '=', record.product_id.tool_material_id)])
|
[('id', '=', record.product_id.tool_material_id)])
|
||||||
if tool_material_search:
|
if tool_material_search:
|
||||||
record.tool_material_search_id = tool_material_search
|
record.tool_material_status = '未入库'
|
||||||
|
record.tool_material_search_id = tool_material_search.id
|
||||||
|
elif record.product_id.categ_id.name == '夹具':
|
||||||
|
fixture_material_search = self.env['sf.fixture.material.search'].sudo().search(
|
||||||
|
[('id', '=', record.product_id.fixture_material_search_id)])
|
||||||
|
if fixture_material_search:
|
||||||
|
record.tool_material_status = '未入库'
|
||||||
|
record.fixture_material_search_id = fixture_material_search.id
|
||||||
return records
|
return records
|
||||||
|
|
||||||
|
|
||||||
@@ -154,6 +165,7 @@ class ProductProduct(models.Model):
|
|||||||
_inherit = 'product.product'
|
_inherit = 'product.product'
|
||||||
|
|
||||||
tool_material_id = fields.Char('刀具物料搜索模型ID')
|
tool_material_id = fields.Char('刀具物料搜索模型ID')
|
||||||
|
fixture_material_search_id = fields.Char('夹具物料搜索模型ID')
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
@@ -164,4 +176,9 @@ class ProductProduct(models.Model):
|
|||||||
'product_id': record.id
|
'product_id': record.id
|
||||||
})
|
})
|
||||||
record.tool_material_id = tool_material.id
|
record.tool_material_id = tool_material.id
|
||||||
|
elif record.categ_id.name == '夹具':
|
||||||
|
fixture_material = self.env['sf.fixture.material.search'].sudo().create({
|
||||||
|
'product_id': record.id
|
||||||
|
})
|
||||||
|
record.fixture_material_search_id = fixture_material.id
|
||||||
return records
|
return records
|
||||||
|
|||||||
@@ -2,308 +2,6 @@
|
|||||||
from odoo import fields, models, api, SUPERUSER_ID
|
from odoo import fields, models, api, SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
# from odoo.exceptions import ValidationError
|
|
||||||
|
|
||||||
|
|
||||||
# 刀具物料搜索(待删除)
|
|
||||||
class SfToolMaterialSearch(models.Model):
|
|
||||||
_name = 'sf.tool.material.search'
|
|
||||||
_description = '刀具物料搜索'
|
|
||||||
|
|
||||||
sequence = fields.Integer('序号')
|
|
||||||
code = fields.Char('编码')
|
|
||||||
name = fields.Char('名称', required=True)
|
|
||||||
# 关联刀具类型
|
|
||||||
mrs_cutting_tool_type_id = fields.Many2one(
|
|
||||||
'sf.cutting.tool.type', '刀具类型',
|
|
||||||
domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]", required=True)
|
|
||||||
# 关联刀具物料名称
|
|
||||||
mrs_cutting_tool_material_name = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料名称',
|
|
||||||
store=True)
|
|
||||||
cutting_tool_type = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料类型', store=True)
|
|
||||||
mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌', required=True,
|
|
||||||
domain="[('tag_ids.name', 'ilike', '刀具')]")
|
|
||||||
# 关联刀具型号
|
|
||||||
# mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', '刀具型号')
|
|
||||||
|
|
||||||
# 关联刀具物料模型
|
|
||||||
mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料',
|
|
||||||
group_expand='_read_group_mrs_cutting_tool_material_ids',
|
|
||||||
required=True)
|
|
||||||
cutting_tool_material_name = fields.Char(string='物料名称', invisible=True)
|
|
||||||
|
|
||||||
@api.onchange('mrs_cutting_tool_material_id')
|
|
||||||
def _onchange_mrs_cutting_tool_material_id(self):
|
|
||||||
for record in self:
|
|
||||||
if record:
|
|
||||||
record.cutting_tool_material_name = record.mrs_cutting_tool_material_id.name
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _read_group_mrs_cutting_tool_material_ids(self, categories, domain, order):
|
|
||||||
mrs_cutting_tool_material_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
|
||||||
return categories.browse(mrs_cutting_tool_material_ids)
|
|
||||||
|
|
||||||
# 刀片特有字段
|
|
||||||
blade_code = fields.Char('刀片编码', readonly=True)
|
|
||||||
blade_length = fields.Float('刀片长度L(mm)')
|
|
||||||
blade_width = fields.Float('刀片宽度D(mm)')
|
|
||||||
blade_height = fields.Float('刀片高度T(mm)')
|
|
||||||
blade_top_angle = fields.Float('刀片顶角(°)')
|
|
||||||
blade_front_angle = fields.Float('刀片前角(°)')
|
|
||||||
blade_rear_angle = fields.Float('刀片后角(°)')
|
|
||||||
blade_main_included_angle = fields.Float('刀片主偏角(°)')
|
|
||||||
blade_r_angle = fields.Float('刀片R角(°)')
|
|
||||||
blade_hardness = fields.Integer('刀片加工硬度')
|
|
||||||
blade_accuracy = fields.Char('刀片精度等级')
|
|
||||||
blade_coating_material_id = fields.Char('刀片涂层材质')
|
|
||||||
blade_radius = fields.Float('刀片刀尖半径(mm)')
|
|
||||||
blade_nut = fields.Float('刀片配对螺母(mm)')
|
|
||||||
mrs_cutting_tool_model_blade_cutter_bar_ids = fields.Many2many(
|
|
||||||
'sf.cutting_tool.standard.library',
|
|
||||||
relation='sf_tool_material_search_blade_cutter_bar_rel',
|
|
||||||
column1='model_id_1',
|
|
||||||
column2='model_id_2',
|
|
||||||
domain="[('cutting_tool_type', '=', '刀杆')]",
|
|
||||||
string='适用刀杆型号',
|
|
||||||
default=lambda self: [], # 使用空列表作为默认值
|
|
||||||
)
|
|
||||||
mrs_cutting_tool_model_blade_cutter_pad_ids = fields.Many2many(
|
|
||||||
'sf.cutting_tool.standard.library',
|
|
||||||
relation='sf_tool_material_search_blade_cutter_pad_rel',
|
|
||||||
column1='model_id_1',
|
|
||||||
column2='model_id_2',
|
|
||||||
domain="[('cutting_tool_type', '=', '刀盘')]",
|
|
||||||
string='适用刀盘型号',
|
|
||||||
default=lambda self: [], # 使用空列表作为默认值
|
|
||||||
)
|
|
||||||
|
|
||||||
# 整体式刀具特有字段
|
|
||||||
integral_code = fields.Char('整体式刀具编码', readonly=True)
|
|
||||||
integral_total_length = fields.Float('整体式刀具总长度(mm)', digits=(6, 1))
|
|
||||||
integral_shank_length = fields.Float('整体式刀具柄部长度(mm)', digits=(6, 1))
|
|
||||||
integral_blade_length = fields.Float('整体式刀具刃部长度(mm)', digits=(6, 1))
|
|
||||||
integral_neck_length = fields.Float('整体式刀具颈部长度(mm)', digits=(6, 1))
|
|
||||||
integral_shank_diameter = fields.Float('整体式刀具柄部直径(mm)', digits=(6, 1))
|
|
||||||
integral_blade_diameter = fields.Float('整体式刀具刃部直径(mm)', digits=(6, 1))
|
|
||||||
integral_neck_diameter = fields.Float('整体式刀具颈部直径(mm)', digits=(6, 1))
|
|
||||||
integral_blade_number = fields.Integer('整体式刀具刃数(个)')
|
|
||||||
integral_blade_tip_diameter = fields.Float('整体式刀具刀尖直径(mm)', digits=(6, 1))
|
|
||||||
integral_blade_tip_taper = fields.Float('整体式刀具刀尖锥度(°)', digits=(6, 1))
|
|
||||||
integral_blade_helix_angle = fields.Float('整体式刀具刃部螺旋角(°)', digits=(6, 1))
|
|
||||||
integral_blade_type = fields.Char('整体式刀具刃部类型')
|
|
||||||
integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精')
|
|
||||||
# integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质')
|
|
||||||
integral_hardness = fields.Integer('整体式刀具硬度(HRC)')
|
|
||||||
integral_coating_material = fields.Char('整体式刀具涂层材质')
|
|
||||||
integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6, 1))
|
|
||||||
integral_run_out_accuracy_min = fields.Float('整体式刀具端跳精度min', digits=(6, 1))
|
|
||||||
|
|
||||||
suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image',
|
|
||||||
'rel_machining_product_template_material_search', '适合加工方式',
|
|
||||||
domain=[('type', '=', '加工能力')])
|
|
||||||
blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征',
|
|
||||||
domain=[('type', '=', '刀尖特征')])
|
|
||||||
handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')])
|
|
||||||
cutting_direction_ids = fields.Many2many('maintenance.equipment.image',
|
|
||||||
'rel_cutting_product_template_material_search', '走刀方向',
|
|
||||||
domain=[('type', '=', '走刀方向')])
|
|
||||||
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image',
|
|
||||||
'rel_coolants_product_template_material_search', '适合冷却方式',
|
|
||||||
domain=[('type', '=', '冷却方式')])
|
|
||||||
|
|
||||||
cutting_speed_ids = fields.Many2many('sf.cutting.speed', string='切削速度Vc')
|
|
||||||
feed_per_tooth_ids = fields.Many2many('sf.feed.per.tooth', 'rel_feed_per_tooth_ids', '每齿走刀量fz')
|
|
||||||
|
|
||||||
# @api.constrains('suitable_machining_method_ids')
|
|
||||||
# def _check_suitable_machining_method_ids(self):
|
|
||||||
# for record in self:
|
|
||||||
# if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("适合加工方式不能为空!")
|
|
||||||
#
|
|
||||||
# @api.constrains('blade_tip_characteristics_ids')
|
|
||||||
# def _check_blade_tip_characteristics_ids(self):
|
|
||||||
# for record in self:
|
|
||||||
# if len(record.blade_tip_characteristics_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("刀尖特征不能为空!")
|
|
||||||
# if len(record.blade_tip_characteristics_ids) > 1 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("刀尖特征只能单选!")
|
|
||||||
#
|
|
||||||
# @api.constrains('handle_type_ids')
|
|
||||||
# def _check_handle_type_ids(self):
|
|
||||||
# for record in self:
|
|
||||||
# if len(record.handle_type_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("柄部类型不能为空!")
|
|
||||||
# if len(record.handle_type_ids) > 1 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("柄部类型只能单选!")
|
|
||||||
#
|
|
||||||
# @api.constrains('cutting_direction_ids')
|
|
||||||
# def _check_cutting_direction_ids(self):
|
|
||||||
# for record in self:
|
|
||||||
# if len(record.cutting_direction_ids) == 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("走刀方向不能为空!")
|
|
||||||
#
|
|
||||||
# @api.constrains('suitable_coolant_ids')
|
|
||||||
# def _check_suitable_coolant_ids(self):
|
|
||||||
# for record in self:
|
|
||||||
# if not record.suitable_coolant_ids and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("适合冷却液不能为空!")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_total_length')
|
|
||||||
# def _check_integral_total_length(self):
|
|
||||||
# if self.integral_total_length <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("总长度不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_shank_length')
|
|
||||||
# def _check_integral_shank_length(self):
|
|
||||||
# if self.integral_shank_length <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("柄部长度不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_blade_length')
|
|
||||||
# def _check_integral_blade_length(self):
|
|
||||||
# if self.integral_blade_length <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("刃部长度不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_blade_number')
|
|
||||||
# def _check_integral_blade_number(self):
|
|
||||||
# if self.integral_blade_number <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("刃数不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_shank_diameter')
|
|
||||||
# def _check_integral_shank_diameter(self):
|
|
||||||
# if self.integral_shank_diameter <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("柄部直径不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_blade_diameter')
|
|
||||||
# def _check_integral_blade_diameter(self):
|
|
||||||
# if self.integral_blade_diameter <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("刃部直径不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_run_out_accuracy_min')
|
|
||||||
# def _check_integral_blade_diameter(self):
|
|
||||||
# if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("端跳精度最小(min)不能为0")
|
|
||||||
#
|
|
||||||
# @api.constrains('integral_run_out_accuracy_max')
|
|
||||||
# def _check_integral_run_out_accuracy_max(self):
|
|
||||||
# if self.integral_run_out_accuracy_max <= 0 and self.cutting_tool_type == '整体式刀具':
|
|
||||||
# raise ValidationError("端跳精度最大(max)不能为0")
|
|
||||||
|
|
||||||
# integral_front_angle = fields.Float('整体式刀具前角(°)')
|
|
||||||
# integral_rear_angle = fields.Float('整体式刀具后角(°)')
|
|
||||||
# integral_main_included_angle = fields.Float('整体式刀具主偏角(°)')
|
|
||||||
# integral_accuracy = fields.Float('整体式刀具精度等级')
|
|
||||||
# integral_hardness = fields.Float('整体式刀具加工硬度(HRC)')
|
|
||||||
# integral_coating_material = fields.Char('整体式刀具涂层材质')
|
|
||||||
# integral_nut = fields.Float('整体式刀具配对螺母(mm)')
|
|
||||||
# integral_scope = fields.Char('整体式刀具适用范围')
|
|
||||||
|
|
||||||
# 刀杆特有字段
|
|
||||||
bar_code = fields.Char('刀杆编码', readonly=True)
|
|
||||||
# bar_name = fields.Char('刀杆名称', required=True)
|
|
||||||
bar_c_diameter = fields.Float('刀杆C柄径(mm)')
|
|
||||||
bar_total_length = fields.Float('刀杆L总长(mm)')
|
|
||||||
bar_blade_number = fields.Integer('刀杆刃数')
|
|
||||||
bar_d_diameter = fields.Float('刀杆D刃径(mm)')
|
|
||||||
mrs_cutting_tool_model_bar_blade_ids = fields.Many2many(
|
|
||||||
'sf.cutting_tool.standard.library',
|
|
||||||
relation='sf_tool_material_search_bar_blade_rel',
|
|
||||||
column1='model_id_1',
|
|
||||||
column2='model_id_2',
|
|
||||||
domain="[('cutting_tool_type', '=', '刀片')]",
|
|
||||||
string='刀杆适用刀片型号'
|
|
||||||
)
|
|
||||||
bar_wrench = fields.Float('刀杆配对扳手(mm)')
|
|
||||||
bar_screw = fields.Float('刀杆配备螺丝(mm)')
|
|
||||||
bar_radius = fields.Float('刀杆刀尖圆角半径')
|
|
||||||
bar_accuracy = fields.Char('刀杆精度等级')
|
|
||||||
bar_hardness = fields.Integer('刀杆硬度(°)')
|
|
||||||
bar_scope = fields.Char('刀杆适用范围')
|
|
||||||
|
|
||||||
# 刀盘特有字段
|
|
||||||
pad_code = fields.Char('刀盘编码', readonly=True)
|
|
||||||
# pad_name = fields.Char('刀盘名称', required=True)
|
|
||||||
pad_c_diameter = fields.Float('刀盘C柄径(mm)')
|
|
||||||
pad_total_length = fields.Float('刀盘L总长(mm)')
|
|
||||||
pad_blade_number = fields.Integer('刀盘刃数')
|
|
||||||
pad_d_diameter = fields.Float('刀盘D刃径(mm)')
|
|
||||||
mrs_cutting_tool_model_pad_blade_ids = fields.Many2many(
|
|
||||||
'sf.cutting_tool.standard.library',
|
|
||||||
relation='sf_tool_material_search_pad_blade_rel',
|
|
||||||
column1='model_id_1',
|
|
||||||
column2='model_id_2',
|
|
||||||
domain="[('cutting_tool_type', '=', '刀片')]",
|
|
||||||
string='刀盘适用刀片型号'
|
|
||||||
)
|
|
||||||
pad_wrench = fields.Float('刀盘配对扳手(mm)')
|
|
||||||
pad_screw = fields.Float('刀盘配备螺丝(mm)')
|
|
||||||
pad_radius = fields.Float('刀盘刀尖圆角半径')
|
|
||||||
pad_accuracy = fields.Char('刀盘精度等级')
|
|
||||||
pad_hardness = fields.Integer('刀盘硬度(°)')
|
|
||||||
pad_scope = fields.Char('刀盘适用范围')
|
|
||||||
|
|
||||||
# 刀柄特有字段
|
|
||||||
handle_code = fields.Char('刀柄编码', readonly=True)
|
|
||||||
# 柄长L(mm)、法兰柄长L1(mm)、法兰直径D1(mm)
|
|
||||||
handle_length = fields.Float('刀柄柄长L(mm)')
|
|
||||||
handle_diameter = fields.Float('刀柄直径D(mm)')
|
|
||||||
handle_flange_length = fields.Float('刀柄法兰柄长L1(mm)')
|
|
||||||
handle_flange_diameter = fields.Float('刀柄法兰直径D1(mm)')
|
|
||||||
# 夹持直径min、夹持直径max、径跳精度、最大转速n/min、3D模型图
|
|
||||||
handle_clamping_diameter_min = fields.Float('刀柄夹持直径min')
|
|
||||||
handle_clamping_diameter_max = fields.Float('刀柄夹持直径max')
|
|
||||||
handle_jump_accuracy = fields.Float('刀柄径跳精度')
|
|
||||||
handle_max_speed = fields.Float('刀柄最大转速n/min')
|
|
||||||
handle_weight = fields.Float('刀柄重量(kg)')
|
|
||||||
handle_body_accuracy = fields.Float('刀柄本体精度(mm)')
|
|
||||||
handle_nut = fields.Float('刀柄配对螺母(mm)')
|
|
||||||
mrs_cutting_tool_model_handle_chuck_model_ids = fields.Many2many(
|
|
||||||
'sf.cutting_tool.standard.library',
|
|
||||||
relation='sf_tool_material_search_handle_chuck_rel',
|
|
||||||
column1='model_id_1',
|
|
||||||
column2='model_id_2',
|
|
||||||
domain="[('cutting_tool_type', '=', '夹头')]",
|
|
||||||
string='适用夹头型号'
|
|
||||||
)
|
|
||||||
handle_clamping_range = fields.Float('刀柄夹持范围(mm)')
|
|
||||||
handle_detection_accuracy = fields.Float('刀柄检测精度')
|
|
||||||
handle_detection_hardness = fields.Integer('刀柄检测硬度')
|
|
||||||
handle_standard_speed = fields.Float('刀柄标准转速')
|
|
||||||
|
|
||||||
# 夹头特有字段
|
|
||||||
chuck_code = fields.Char('夹头编码', readonly=True)
|
|
||||||
# chuck_name = fields.Char('夹头名称', required=True)
|
|
||||||
chuck_accuracy = fields.Float('夹头精度(mm)')
|
|
||||||
# 夹持直径min、夹持直径max、3D模型图
|
|
||||||
chuck_clamping_diameter_min = fields.Float('夹头夹持直径min(mm)')
|
|
||||||
chuck_clamping_diameter_max = fields.Float('夹头夹持直径max(mm)')
|
|
||||||
chuck_diameter = fields.Float('夹头外径(mm)')
|
|
||||||
chuck_inner_diameter = fields.Float('夹头内径(mm)')
|
|
||||||
chuck_height = fields.Float('夹头高度(mm)')
|
|
||||||
chuck_nut = fields.Float('夹头配对螺母(mm)')
|
|
||||||
mrs_cutting_tool_model_chuck_handle_model_ids = fields.Many2many(
|
|
||||||
'sf.cutting_tool.standard.library',
|
|
||||||
relation='sf_tool_material_search_chuck_handle_rel',
|
|
||||||
column1='model_id_1',
|
|
||||||
column2='model_id_2',
|
|
||||||
domain="[('cutting_tool_type', '=', '刀柄')]",
|
|
||||||
string='适用刀柄型号'
|
|
||||||
)
|
|
||||||
chuck_clamping_range = fields.Float('夹头夹持范围(mm)')
|
|
||||||
chuck_feature = fields.Char('夹头特性')
|
|
||||||
image = fields.Binary('夹头图片')
|
|
||||||
|
|
||||||
# 数量、采购入库日期、采购批次、供应商、仓库名称、库区、库位、3D模型
|
|
||||||
number = fields.Integer('数量')
|
|
||||||
mrs_materials_model_id = fields.Many2one('sf.materials.model', '材料型号')
|
|
||||||
purchase_date = fields.Date('采购入库日期')
|
|
||||||
purchase_batch = fields.Char('采购批次')
|
|
||||||
supplier = fields.Char('供应商')
|
|
||||||
warehouse_name = fields.Char('仓库名称')
|
|
||||||
warehouse_area = fields.Char('库区')
|
|
||||||
warehouse_location = fields.Char('库位')
|
|
||||||
three_d_model = fields.Many2one('ir.attachment', '3D模型')
|
|
||||||
|
|
||||||
|
|
||||||
class ToolMaterial(models.Model):
|
class ToolMaterial(models.Model):
|
||||||
_name = 'sf.tool.material.search'
|
_name = 'sf.tool.material.search'
|
||||||
_description = '刀具物料搜索'
|
_description = '刀具物料搜索'
|
||||||
@@ -329,8 +27,6 @@ class ToolMaterial(models.Model):
|
|||||||
|
|
||||||
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
|
barcode_ids = fields.One2many('stock.lot', 'tool_material_search_id', string='序列号', readonly=True)
|
||||||
|
|
||||||
active = fields.Boolean(string='已归档', default=True)
|
|
||||||
|
|
||||||
@api.depends('barcode_ids')
|
@api.depends('barcode_ids')
|
||||||
def _compute_number(self):
|
def _compute_number(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ access_sf_tool_transfer_request_information,sf.tool.transfer.request.information
|
|||||||
access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,0
|
access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,0
|
access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
|
|
||||||
|
|
||||||
access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0
|
access_sf_functional_cutting_tool_entity_group_plan_dispatch,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
@@ -29,3 +30,4 @@ access_sf_tool_transfer_request_information_group_plan_dispatch,sf.tool.transfer
|
|||||||
access_sf_functional_tool_assembly_group_plan_dispatch,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_plan_dispatch,1,0,0,0
|
access_sf_functional_tool_assembly_group_plan_dispatch,sf.functional.tool.assembly,model_sf_functional_tool_assembly,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
access_sf_functional_tool_assembly_order_group_plan_dispatch,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_plan_dispatch,1,0,0,0
|
access_sf_functional_tool_assembly_order_group_plan_dispatch,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
|
access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
|
|||||||
|
105
sf_tool_management/views/fixture_material_search_views.xml
Normal file
105
sf_tool_management/views/fixture_material_search_views.xml
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="sf_fixture_material_search_tree" model="ir.ui.view">
|
||||||
|
<field name="name">sf.fixture.material.search.tree</field>
|
||||||
|
<field name="model">sf.fixture.material.search</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="夹具物料查询" create="0">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="fixture_material_id"/>
|
||||||
|
<field name="fixture_model_id"/>
|
||||||
|
<field name="specification_fixture_id"/>
|
||||||
|
<field name="number"/>
|
||||||
|
<field name="usable_num"/>
|
||||||
|
<field name="image" type="image"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="sf_fixture_material_search_form" model="ir.ui.view">
|
||||||
|
<field name="name">sf.fixture.material.search.form</field>
|
||||||
|
<field name="model">sf.fixture.material.search</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="夹具物料查询" create="0">
|
||||||
|
<!-- <header>-->
|
||||||
|
<!-- <button string="夹具物料注册" name="enroll_fixture_material" type="object" class="btn-primary"/>-->
|
||||||
|
<!-- </header>-->
|
||||||
|
<sheet>
|
||||||
|
<div class="oe_title">
|
||||||
|
<h1>
|
||||||
|
<field name="product_id" readonly="1"/>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="name" invisible="1"/>
|
||||||
|
<field name="fixture_material_id"/>
|
||||||
|
<field name="fixture_model_id"/>
|
||||||
|
<field name="specification_fixture_id"/>
|
||||||
|
<field name="number"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="image" type="image"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<group col="3">
|
||||||
|
<group>
|
||||||
|
<field name="usable_num"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="have_been_used_num"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="scrap_num"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<notebook>
|
||||||
|
<page string="序列号">
|
||||||
|
<field name="barcode_ids">
|
||||||
|
<tree create="0">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="tool_material_status"/>
|
||||||
|
<!-- <button string="序列号注册" name="enroll_fixture_material_stock" type="object"-->
|
||||||
|
<!-- class="btn-primary"/>-->
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_fixture_material_search_search" model="ir.ui.view">
|
||||||
|
<field name="name">sf.fixture.material.search.search</field>
|
||||||
|
<field name="model">sf.fixture.material.search</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="夹具物料搜索">
|
||||||
|
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
|
||||||
|
<field name="fixture_material_id" string="夹具型号搜索"/>
|
||||||
|
<field name="specification_fixture_id" string="规格搜索"/>
|
||||||
|
<searchpanel>
|
||||||
|
<field name="fixture_material_id" icon="fa-building" enable_counters="1"/>
|
||||||
|
</searchpanel>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_sf_fixture_material_search" model="ir.actions.act_window">
|
||||||
|
<field name="name">夹具物料查询</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sf.fixture.material.search</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
sequence="25"
|
||||||
|
name="夹具物料查询"
|
||||||
|
id="menu_sf_fixture_material_search"
|
||||||
|
action="action_sf_fixture_material_search"
|
||||||
|
parent="menu_sf_tool_manage"
|
||||||
|
/>
|
||||||
|
</odoo>
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
<menuitem
|
<menuitem
|
||||||
id="menu_sf_functional_cutting_tool"
|
id="menu_sf_functional_cutting_tool"
|
||||||
parent="menu_sf_tool_manage"
|
parent="menu_sf_tool_manage"
|
||||||
name="功能刀具列表"
|
name="功能刀具"
|
||||||
sequence="4"
|
sequence="2"
|
||||||
action="sf_function_tool_entry_list_view_act"
|
action="sf_function_tool_entry_list_view_act"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
sequence="6"
|
sequence="6"
|
||||||
name="功能刀具出入库记录"
|
name="功能刀具出入库"
|
||||||
id="menu_sf_function_tool_entry_exit_records"
|
id="menu_sf_function_tool_entry_exit_records"
|
||||||
action="sf_inbound_and_outbound_records_of_functional_tools_view_act"
|
action="sf_inbound_and_outbound_records_of_functional_tools_view_act"
|
||||||
parent="menu_sf_tool_manage"
|
parent="menu_sf_tool_manage"
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
sequence="2"
|
sequence="4"
|
||||||
name="功能刀具组装"
|
name="功能刀具组装"
|
||||||
id="menu_sf_functional_tool_assembly"
|
id="menu_sf_functional_tool_assembly"
|
||||||
action="sf_functional_tool_assembly_view_act"
|
action="sf_functional_tool_assembly_view_act"
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
<field name="model">sf.tool.material.search</field>
|
<field name="model">sf.tool.material.search</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="刀具物料查询" create="0">
|
<form string="刀具物料查询" create="0">
|
||||||
<header>
|
<!-- <header>-->
|
||||||
<button string="刀具物料注册" name="enroll_tool_material" type="object" class="btn-primary"/>
|
<!-- <button string="刀具物料注册" name="enroll_tool_material" type="object" class="btn-primary"/>-->
|
||||||
</header>
|
<!-- </header>-->
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<tree>
|
<tree>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="tool_material_status"/>
|
<field name="tool_material_status"/>
|
||||||
<button name="enroll_tool_material_stock" string="序列号注册" type="object" class="btn-primary"/>
|
<!-- <button name="enroll_tool_material_stock" string="序列号注册" type="object" class="btn-primary"/>-->
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
@@ -82,7 +82,6 @@
|
|||||||
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
|
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
|
||||||
<field name="cutting_tool_standard_library_id" string="刀具型号搜索"/>
|
<field name="cutting_tool_standard_library_id" string="刀具型号搜索"/>
|
||||||
<field name="specification_id" string="规格搜索"/>
|
<field name="specification_id" string="规格搜索"/>
|
||||||
<filter string="已归档" name="inactive" domain="[('active', '=', False)]"/>
|
|
||||||
<searchpanel>
|
<searchpanel>
|
||||||
<field name="cutting_tool_material_id" icon="fa-building" enable_counters="1"/>
|
<field name="cutting_tool_material_id" icon="fa-building" enable_counters="1"/>
|
||||||
</searchpanel>
|
</searchpanel>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class ToolChangeRequirementInformation(models.TransientModel):
|
|||||||
_description = '换刀需求信息'
|
_description = '换刀需求信息'
|
||||||
|
|
||||||
code = fields.Char('编码', readonly=True)
|
code = fields.Char('编码', readonly=True)
|
||||||
rfid = fields.Char('rfid', readonly=True)
|
rfid = fields.Char('Rfid', readonly=True)
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
|
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=True)
|
||||||
name = fields.Char('名称', related='maintenance_equipment_id.name', store=True, readonly=True)
|
name = fields.Char('名称', related='maintenance_equipment_id.name', store=True, readonly=True)
|
||||||
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True)
|
maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True)
|
||||||
@@ -225,8 +225,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 整体式刀具型号
|
# 整体式刀具型号
|
||||||
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
|
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),
|
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),
|
||||||
('quant_ids.location_id.name', 'in', ['刀具房']),
|
('tool_material_status', '=', '可用')])
|
||||||
('quant_ids.quantity', '>', 0)])
|
|
||||||
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
|
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
|
||||||
related='integral_code_id.product_id.cutting_tool_model_id')
|
related='integral_code_id.product_id.cutting_tool_model_id')
|
||||||
integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
|
integral_name = fields.Char('整体式刀具名称', related='integral_code_id.product_id.name')
|
||||||
@@ -238,8 +237,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 刀片型号
|
# 刀片型号
|
||||||
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
|
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片'),
|
||||||
('quant_ids.location_id.name', 'in', ['刀具房']),
|
('tool_material_status', '=', '可用')])
|
||||||
('quant_ids.quantity', '>', 0)])
|
|
||||||
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||||
related='blade_code_id.product_id.cutting_tool_model_id')
|
related='blade_code_id.product_id.cutting_tool_model_id')
|
||||||
blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name')
|
blade_name = fields.Char('刀片名称', related='blade_code_id.product_id.name')
|
||||||
@@ -250,8 +248,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 刀杆型号
|
# 刀杆型号
|
||||||
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
|
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'),
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆'),
|
||||||
('quant_ids.location_id.name', 'in', ['刀具房']),
|
('tool_material_status', '=', '可用')])
|
||||||
('quant_ids.quantity', '>', 0)])
|
|
||||||
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||||
related='bar_code_id.product_id.cutting_tool_model_id')
|
related='bar_code_id.product_id.cutting_tool_model_id')
|
||||||
bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
|
bar_name = fields.Char('刀杆名称', related='bar_code_id.product_id.name')
|
||||||
@@ -262,8 +259,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 刀盘型号
|
# 刀盘型号
|
||||||
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
|
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'),
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘'),
|
||||||
('quant_ids.location_id.name', 'in', ['刀具房']),
|
('tool_material_status', '=', '可用')])
|
||||||
('quant_ids.quantity', '>', 0)])
|
|
||||||
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||||
related='pad_code_id.product_id.cutting_tool_model_id')
|
related='pad_code_id.product_id.cutting_tool_model_id')
|
||||||
pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
|
pad_name = fields.Char('刀盘名称', related='pad_code_id.product_id.name')
|
||||||
@@ -274,8 +270,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 刀柄型号
|
# 刀柄型号
|
||||||
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
|
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True,
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'),
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'),
|
||||||
('quant_ids.location_id.name', 'in', ['刀具房']),
|
('tool_material_status', '=', '可用')])
|
||||||
('quant_ids.quantity', '>', 0)])
|
|
||||||
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
|
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号',
|
||||||
related='handle_code_id.product_id.cutting_tool_model_id')
|
related='handle_code_id.product_id.cutting_tool_model_id')
|
||||||
handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name')
|
handle_name = fields.Char('刀柄名称', related='handle_code_id.product_id.name')
|
||||||
@@ -286,8 +281,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 夹头型号
|
# 夹头型号
|
||||||
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True,
|
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True,
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'),
|
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头'),
|
||||||
('quant_ids.location_id.name', 'in', ['刀具房']),
|
('tool_material_status', '=', '可用')])
|
||||||
('quant_ids.quantity', '>', 0)])
|
|
||||||
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||||
related='chuck_code_id.product_id.cutting_tool_model_id')
|
related='chuck_code_id.product_id.cutting_tool_model_id')
|
||||||
chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
|
chuck_name = fields.Char('夹头名称', related='chuck_code_id.product_id.name')
|
||||||
@@ -329,7 +323,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
|
|
||||||
# 组装功能刀具参数信息
|
# 组装功能刀具参数信息
|
||||||
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
|
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
|
||||||
rfid = fields.Char('rfid', required=True)
|
rfid = fields.Char('Rfid', required=True)
|
||||||
tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_tool_code')
|
tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_tool_code')
|
||||||
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name')
|
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name')
|
||||||
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
|
||||||
@@ -461,7 +455,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
if obj.rfid:
|
if obj.rfid:
|
||||||
tool_entity = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', obj.rfid)])
|
tool_entity = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', obj.rfid)])
|
||||||
if tool_entity:
|
if tool_entity:
|
||||||
raise ValidationError('【%s】的rfid已被使用,请重新录入!!!' % obj.rfid)
|
raise ValidationError('【%s】的Rfid已被使用,请重新录入!!!' % obj.rfid)
|
||||||
|
|
||||||
def functional_tool_assembly(self):
|
def functional_tool_assembly(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import requests
|
|||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.osv import expression
|
from odoo.osv import expression
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
|
||||||
|
|
||||||
class SfLocation(models.Model):
|
class SfLocation(models.Model):
|
||||||
@@ -388,7 +388,6 @@ class ShelfLocation(models.Model):
|
|||||||
record.product_id = False
|
record.product_id = False
|
||||||
# record.location_status = '空闲'
|
# record.location_status = '空闲'
|
||||||
|
|
||||||
|
|
||||||
# 调取获取货位信息接口
|
# 调取获取货位信息接口
|
||||||
def get_sf_shelf_location_info(self):
|
def get_sf_shelf_location_info(self):
|
||||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
@@ -414,7 +413,8 @@ class ShelfLocation(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class Sf_stock_move_line(models.Model):
|
class Sf_stock_move_line(models.Model):
|
||||||
_inherit = 'stock.move.line'
|
_name = 'stock.move.line'
|
||||||
|
_inherit = ['stock.move.line', 'printing.utils']
|
||||||
|
|
||||||
current_location_id = fields.Many2one(
|
current_location_id = fields.Many2one(
|
||||||
'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True)
|
'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True)
|
||||||
@@ -465,36 +465,127 @@ class Sf_stock_move_line(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.lot_qr_code = False
|
record.lot_qr_code = False
|
||||||
|
|
||||||
def print_qr_code(self):
|
def print_single_method(self):
|
||||||
self.ensure_one() # 确保这个方法只为一个记录调用
|
self.ensure_one()
|
||||||
# if not self.lot_id:
|
|
||||||
# raise UserError("没有找到序列号。")
|
|
||||||
# 假设_lot_qr_code方法已经生成了二维码并保存在字段中
|
|
||||||
qr_code_data = self.lot_qr_code
|
qr_code_data = self.lot_qr_code
|
||||||
if not qr_code_data:
|
if not qr_code_data:
|
||||||
raise UserError("没有找到二维码数据。")
|
raise UserError("没有找到二维码数据。")
|
||||||
|
lot_name = self.lot_name
|
||||||
|
# host = "192.168.50.110" # 可以根据实际情况修改
|
||||||
|
# port = 9100 # 可以根据实际情况修改
|
||||||
|
|
||||||
# 生成下载链接或直接触发下载
|
# 获取默认打印机配置
|
||||||
# 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
|
printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
|
||||||
attachment = self.env['ir.attachment'].sudo().create({
|
if not printer_config:
|
||||||
'datas': self.lot_qr_code,
|
raise UserError('请先配置打印机')
|
||||||
'type': 'binary',
|
host = printer_config.printer_id.ip_address
|
||||||
'description': '二维码图片',
|
port = printer_config.printer_id.port
|
||||||
'name': self.lot_name + '.png',
|
self.print_qr_code(lot_name, host, port)
|
||||||
# 'res_id': invoice.id,
|
|
||||||
# 'res_model': 'stock.picking',
|
# 返回当前wizard页面
|
||||||
'public': True,
|
# base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
'mimetype': 'application/x-png',
|
# return {
|
||||||
# 'model_name': 'stock.picking',
|
# 'type': 'ir.actions.act_url',
|
||||||
})
|
# 'url': str(base_url) + download_url,
|
||||||
# 返回附件的下载链接
|
# 'target': 'self',
|
||||||
download_url = '/web/content/%s?download=true' % attachment.id
|
# }
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
# 获取当前wizard的视图ID或其他标识信息
|
||||||
return {
|
view_id = self.env.context.get('view_id')
|
||||||
'type': 'ir.actions.act_url',
|
# 构造返回wizard页面的action字典
|
||||||
'url': str(base_url) + download_url,
|
action = {
|
||||||
'target': 'self',
|
'type': 'ir.actions.act_window',
|
||||||
|
'name': '返回 Wizard',
|
||||||
|
'res_model': 'stock.move', # 替换为你的wizard模型名称
|
||||||
|
'view_mode': 'form',
|
||||||
|
'view_id': view_id, # 如果需要基于特定的视图返回
|
||||||
|
'target': 'new', # 如果需要在新的窗口或标签页打开
|
||||||
|
'res_id': self.id, # 如果你想要返回当前记录的视图
|
||||||
}
|
}
|
||||||
|
return action
|
||||||
|
|
||||||
|
# def generate_zpl_code(self, code):
|
||||||
|
# # 初始化ZPL代码字符串
|
||||||
|
# zpl_code = "^XA\n"
|
||||||
|
# zpl_code += "^CW1,E:SIMSUN.TTF^FS\n"
|
||||||
|
# zpl_code += "^CI28\n"
|
||||||
|
#
|
||||||
|
# # 设置二维码位置
|
||||||
|
# zpl_code += "^FO50,50\n" # 调整二维码位置,使其与资产编号在同一行
|
||||||
|
# zpl_code += f"^BQN,2,6^FDLM,B0093{code}^FS\n"
|
||||||
|
#
|
||||||
|
# # 设置资产编号文本位置
|
||||||
|
# zpl_code += "^FO300,60\n" # 资产编号文本的位置,与二维码在同一行
|
||||||
|
# zpl_code += "^A1N,45,45^FD编码名称: ^FS\n"
|
||||||
|
#
|
||||||
|
# # 设置{code}文本位置
|
||||||
|
# # 假设{code}文本需要位于资产编号和二维码下方,中间位置
|
||||||
|
# # 设置{code}文本位置并启用自动换行
|
||||||
|
# zpl_code += "^FO300,120\n" # {code}文本的起始位置
|
||||||
|
# zpl_code += "^FB500,4,0,L,0\n" # 定义一个宽度为500点的文本框,最多4行,左对齐
|
||||||
|
# zpl_code += f"^A1N,40,40^FD{code}^FS\n"
|
||||||
|
#
|
||||||
|
# # 在{code}文本框周围绘制线框
|
||||||
|
# # 假设线框的外部尺寸为宽度500点,高度200点
|
||||||
|
# # zpl_code += "^FO300,110^GB500,200,2^FS\n" # 绘制线框,边框粗细为2点
|
||||||
|
#
|
||||||
|
# zpl_code += "^PQ1,0,1,Y\n"
|
||||||
|
# zpl_code += "^XZ\n"
|
||||||
|
# return zpl_code
|
||||||
|
#
|
||||||
|
# def send_to_printer(self, host, port, zpl_code):
|
||||||
|
# # 将ZPL代码转换为字节串
|
||||||
|
# print('zpl_code', zpl_code)
|
||||||
|
# zpl_bytes = zpl_code.encode('utf-8')
|
||||||
|
# print(zpl_bytes)
|
||||||
|
#
|
||||||
|
# # 创建socket对象
|
||||||
|
# mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
# try:
|
||||||
|
# mysocket.connect((host, port)) # 连接到打印机
|
||||||
|
# mysocket.send(zpl_bytes) # 发送ZPL代码
|
||||||
|
# print("ZPL code sent to printer successfully.")
|
||||||
|
# except Exception as e:
|
||||||
|
# print(f"Error with the connection: {e}")
|
||||||
|
# finally:
|
||||||
|
# mysocket.close() # 关闭连接
|
||||||
|
#
|
||||||
|
# def print_qr_code(self):
|
||||||
|
# self.ensure_one() # 确保这个方法只为一个记录调用
|
||||||
|
# # if not self.lot_id:
|
||||||
|
# # raise UserError("没有找到序列号。")
|
||||||
|
# # 假设_lot_qr_code方法已经生成了二维码并保存在字段中
|
||||||
|
# qr_code_data = self.lot_qr_code
|
||||||
|
# if not qr_code_data:
|
||||||
|
# raise UserError("没有找到二维码数据。")
|
||||||
|
# # 生成ZPL代码
|
||||||
|
# zpl_code = self.generate_zpl_code(self.lot_id.name)
|
||||||
|
# # 设置打印机的IP地址和端口号
|
||||||
|
# host = "192.168.50.110"
|
||||||
|
# port = 9100
|
||||||
|
# # 发送ZPL代码到打印机
|
||||||
|
# self.send_to_printer(host, port, zpl_code)
|
||||||
|
#
|
||||||
|
# # # 生成下载链接或直接触发下载
|
||||||
|
# # # 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
|
||||||
|
# # attachment = self.env['ir.attachment'].sudo().create({
|
||||||
|
# # 'datas': self.lot_qr_code,
|
||||||
|
# # 'type': 'binary',
|
||||||
|
# # 'description': '二维码图片',
|
||||||
|
# # 'name': self.lot_name + '.png',
|
||||||
|
# # # 'res_id': invoice.id,
|
||||||
|
# # # 'res_model': 'stock.picking',
|
||||||
|
# # 'public': True,
|
||||||
|
# # 'mimetype': 'application/x-png',
|
||||||
|
# # # 'model_name': 'stock.picking',
|
||||||
|
# # })
|
||||||
|
# # # 返回附件的下载链接
|
||||||
|
# # download_url = '/web/content/%s?download=true' % attachment.id
|
||||||
|
# # base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
# # return {
|
||||||
|
# # 'type': 'ir.actions.act_url',
|
||||||
|
# # 'url': str(base_url) + download_url,
|
||||||
|
# # 'target': 'self',
|
||||||
|
# # }
|
||||||
|
|
||||||
# # # 定义一个方法,用于根据序列号生成二维码
|
# # # 定义一个方法,用于根据序列号生成二维码
|
||||||
# # @api.depends('lot_id')
|
# # @api.depends('lot_id')
|
||||||
@@ -630,6 +721,17 @@ class Sf_stock_move_line(models.Model):
|
|||||||
class SfStockPicking(models.Model):
|
class SfStockPicking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
|
check_in = fields.Char(string='查询是否为入库单', compute='_check_is_in')
|
||||||
|
|
||||||
|
@api.depends('name')
|
||||||
|
def _check_is_in(self):
|
||||||
|
"""
|
||||||
|
判断是否为出库单
|
||||||
|
"""
|
||||||
|
if self.name:
|
||||||
|
is_check_in = self.name.split('/')
|
||||||
|
self.check_in = is_check_in[1]
|
||||||
|
|
||||||
def button_validate(self):
|
def button_validate(self):
|
||||||
"""
|
"""
|
||||||
重写验证方法,当验证时意味着调拨单已经完成,已经移动到了目标货位,所以需要将当前货位的状态改为空闲
|
重写验证方法,当验证时意味着调拨单已经完成,已经移动到了目标货位,所以需要将当前货位的状态改为空闲
|
||||||
@@ -642,6 +744,20 @@ class SfStockPicking(models.Model):
|
|||||||
line.current_location_id.location_status = '空闲'
|
line.current_location_id.location_status = '空闲'
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# def print_all_barcode(self):
|
||||||
|
# """
|
||||||
|
# 打印所有编码
|
||||||
|
# """
|
||||||
|
# print('================')
|
||||||
|
# for record in self.move_ids_without_package:
|
||||||
|
# print('record', record)
|
||||||
|
# print('record.move_line_ids', record.move_line_ids)
|
||||||
|
#
|
||||||
|
# # record.move_line_ids.print_qr_code()
|
||||||
|
#
|
||||||
|
# print('record.move_line_ids.lot_id', record.move_line_ids.lot_id)
|
||||||
|
# print('record.move_line_ids.lot_id.name', record.move_line_ids.lot_id.name)
|
||||||
|
|
||||||
|
|
||||||
class SfProcurementGroup(models.Model):
|
class SfProcurementGroup(models.Model):
|
||||||
_inherit = 'procurement.group'
|
_inherit = 'procurement.group'
|
||||||
@@ -815,7 +931,8 @@ class SfStockScrap(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class CustomStockMove(models.Model):
|
class CustomStockMove(models.Model):
|
||||||
_inherit = 'stock.move'
|
_name = 'stock.move'
|
||||||
|
_inherit = ['stock.move', 'printing.utils']
|
||||||
|
|
||||||
def action_assign_serial_show_details(self):
|
def action_assign_serial_show_details(self):
|
||||||
# 首先执行原有逻辑
|
# 首先执行原有逻辑
|
||||||
@@ -844,3 +961,31 @@ class CustomStockMove(models.Model):
|
|||||||
binary_data = buffer.getvalue()
|
binary_data = buffer.getvalue()
|
||||||
data = base64.b64encode(binary_data).decode() # 确保返回的是字符串形式的数据
|
data = base64.b64encode(binary_data).decode() # 确保返回的是字符串形式的数据
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def print_all_barcode(self):
|
||||||
|
"""
|
||||||
|
打印所有编码
|
||||||
|
"""
|
||||||
|
print('================')
|
||||||
|
for record in self.move_line_ids:
|
||||||
|
print('record', record)
|
||||||
|
if not record.lot_name:
|
||||||
|
continue
|
||||||
|
record.ensure_one()
|
||||||
|
# qr_code_data = record.lot_qr_code
|
||||||
|
# if not qr_code_data:
|
||||||
|
# raise UserError("没有找到二维码数据。")
|
||||||
|
lot_name = record.lot_name
|
||||||
|
# todo 待控制
|
||||||
|
if not lot_name:
|
||||||
|
raise ValidationError("请先分配序列号")
|
||||||
|
# host = "192.168.50.110" # 可以根据实际情况修改
|
||||||
|
# port = 9100 # 可以根据实际情况修改
|
||||||
|
|
||||||
|
# 获取默认打印机配置
|
||||||
|
printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
|
||||||
|
if not printer_config:
|
||||||
|
raise UserError('请先配置打印机')
|
||||||
|
host = printer_config.printer_id.ip_address
|
||||||
|
port = printer_config.printer_id.port
|
||||||
|
record.print_qr_code(lot_name, host, port)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='product_uom_id']" position="after">
|
<xpath expr="//field[@name='product_uom_id']" position="after">
|
||||||
<field name="lot_qr_code" widget="image"/>
|
<field name="lot_qr_code" widget="image"/>
|
||||||
<button name="print_qr_code" string="打印编码" type="object" class="oe_highlight"/>
|
<button name="print_single_method" string="打印编码" type="object" class="oe_highlight"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -103,6 +103,11 @@
|
|||||||
groups="sf_warehouse.group_sf_stock_user" data-hotkey="k"/>
|
groups="sf_warehouse.group_sf_stock_user" data-hotkey="k"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
<!-- <xpath expr="//form//sheet//notebook//page//field[@name='move_ids_without_package']" position="before"> -->
|
||||||
|
<!-- <field name="check_in" invisible="True"/> -->
|
||||||
|
<!-- <button name="print_all_barcode" string="打印所有编码" type="object" attrs="{'invisible': [('check_in', '!=', 'IN')]}"/> -->
|
||||||
|
<!-- </xpath> -->
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -135,5 +140,19 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="sf_view_stock_move_operations" model="ir.ui.view">
|
||||||
|
<field name="name">sf.stock.move.operations.form</field>
|
||||||
|
<field name="model">stock.move</field>
|
||||||
|
<field name="inherit_id" ref="stock.view_stock_move_operations"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<!-- <xpath expr="//form//field[@name='move_line_ids']" position="before"> -->
|
||||||
|
<!-- <button name="print_all_barcode" type="object" string="打印所有编码"/> -->
|
||||||
|
<!-- </xpath> -->
|
||||||
|
<xpath expr="//form//field[@name='product_id']" position="before">
|
||||||
|
<button name="print_all_barcode" type="object" string="打印所有编码" class="oe_highlight"/> -->
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user