From e2c13a819453e5cdc665d0c5446f6d67b0a42f81 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Wed, 18 Oct 2023 17:34:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E7=BB=84=E8=A3=85=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E7=9A=84=E5=85=AD=E4=B8=AA=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=89=A9=E6=96=99=E5=AF=B9=E8=B1=A1=E7=9A=84=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8F=B7=E7=BB=91=E5=AE=9A=E5=BA=93=E5=AD=98=E7=9A=84=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E5=BA=8F=E5=88=97=E5=8F=B7=EF=BC=8C?= =?UTF-8?q?2=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E5=92=8C=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E8=A3=85=E7=BB=84=E8=A3=85=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=9A=84=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 36 ++- sf_tool_management/views/tool_base_views.xml | 248 ++++++++++++----- sf_tool_management/wizard/wizard.py | 264 ++++++------------- sf_tool_management/wizard/wizard_view.xml | 185 +++++++++---- 4 files changed, 418 insertions(+), 315 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 664876b1..a55f4f17 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -752,40 +752,38 @@ class FunctionalToolAssembly(models.Model): functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')]) - integral_code = fields.Char('整体式刀具序列号', readonly=True) + integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True) + cutting_tool_integral_model_id = fields.Many2one('sf.cutting.tool.material', string='整体式刀具型号', readonly=True) integral_name = fields.Char('整体式刀具名称', readonly=True) - sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', '整体式刀具品牌', readonly=True, domain="[('tag_ids.name', 'ilike', '刀具')]") + sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True) + # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')]) - blade_code = fields.Char('刀片序列号', readonly=True) + blade_code_id = fields.Many2one('stock.lot', '刀片序列号', readonly=True) + cutting_tool_blade_model_id = fields.Many2one('sf.cutting.tool.material', string='刀片型号', readonly=True) blade_name = fields.Char('刀片名称', readonly=True) sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True) + # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')]) - bar_code = fields.Char('刀杆序列号', readonly=True) + bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True) + cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting.tool.material', string='刀杆型号', readonly=True) bar_name = fields.Char('刀杆名称', readonly=True) sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True) + # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')]) - pad_code = fields.Char('刀盘序列号', readonly=True) + pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True) + cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting.tool.material', string='刀盘型号', readonly=True) pad_name = fields.Char('刀盘名称', readonly=True) sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')]) - handle_code = fields.Char('刀柄序列号', readonly=True) + handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True) + cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting.tool.material', string='刀柄型号', readonly=True) handle_name = fields.Char('刀柄名称', readonly=True) sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) + # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')]) - chuck_code = fields.Char('夹头序列号', readonly=True) + chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', readonly=True) + cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting.tool.material', string='夹头型号', readonly=True) chuck_name = fields.Char('夹头名称', readonly=True) sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index aba086ca..1e079896 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -1106,72 +1106,192 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
+ +
+ + + + + + + + + + + + + + + + +
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 37f39760..791f30ac 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -137,196 +137,98 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 功能刀具组装信息 # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=False, - domain=[('cutting_tool_material_id', '=', '整体式刀具')]) - integral_code = fields.Char('整体式刀具序列号', readonly=True, compute='_compute_integral_code') - integral_name = fields.Char('整体式刀具名称', readonly=True, compute='_compute_integral_name') - sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', '整体式刀具品牌', readonly=True, - compute='_compute_sf_tool_brand_id_1') - - @api.depends('cutting_tool_integral_model_id') - def _compute_integral_code(self): - for record in self: - if record.cutting_tool_integral_model_id: - self.integral_code = record.cutting_tool_integral_model_id.code - else: - self.integral_code = None - - @api.depends('cutting_tool_integral_model_id') - def _compute_integral_name(self): - for record in self: - if record.cutting_tool_integral_model_id: - self.integral_name = record.cutting_tool_integral_model_id.name - else: - self.integral_name = None - - @api.depends('cutting_tool_integral_model_id') - def _compute_sf_tool_brand_id_1(self): - for record in self: - if record.cutting_tool_integral_model_id: - self.sf_tool_brand_id_1 = record.cutting_tool_integral_model_id.brand_id.id - else: - self.sf_tool_brand_id_1 = None + integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', + domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具')]) + cutting_tool_integral_model_id = fields.Many2one('sf.cutting.tool.material', string='整体式刀具型号', readonly=True) + integral_name = fields.Char('整体式刀具名称', readonly=True) + sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True) # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=False, - domain=[('cutting_tool_material_id', '=', '刀片')]) - blade_code = fields.Char('刀片序列号', readonly=True, compute='_compute_blade_code') - blade_name = fields.Char('刀片名称', readonly=True, compute='_compute_blade_name') - sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True, - compute='_compute_sf_tool_brand_id_2') - - @api.depends('cutting_tool_blade_model_id') - def _compute_blade_code(self): - for record in self: - if record.cutting_tool_blade_model_id: - self.blade_code = self.cutting_tool_blade_model_id.code - else: - self.blade_code = None - - @api.depends('cutting_tool_blade_model_id') - def _compute_blade_name(self): - for record in self: - if record.cutting_tool_blade_model_id: - self.blade_name = self.cutting_tool_blade_model_id.name - else: - self.blade_name = None - - @api.depends('cutting_tool_blade_model_id') - def _compute_sf_tool_brand_id_2(self): - for record in self: - if record.cutting_tool_blade_model_id: - self.sf_tool_brand_id_2 = self.cutting_tool_blade_model_id.brand_id.id - else: - self.sf_tool_brand_id_2 = None + blade_code_id = fields.Many2one('stock.lot', '刀片序列号', + domain=[('product_id.cutting_tool_material_id.name', '=', '刀片')]) + cutting_tool_blade_model_id = fields.Many2one('sf.cutting.tool.material', string='刀片型号', readonly=True) + blade_name = fields.Char('刀片名称', readonly=True) + sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True) # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=False, - domain=[('cutting_tool_material_id', '=', '刀杆')]) - bar_code = fields.Char('刀杆序列号', readonly=True, compute='_compute_bar_code') - bar_name = fields.Char('刀杆名称', readonly=True, compute='_compute_bar_name') - sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True, - compute='_compute_sf_tool_brand_id_3') - - @api.depends('cutting_tool_cutterbar_model_id') - def _compute_bar_code(self): - for record in self: - if record.cutting_tool_cutterbar_model_id: - self.bar_code = self.cutting_tool_cutterbar_model_id.code - else: - self.bar_code = None - - @api.depends('cutting_tool_cutterbar_model_id') - def _compute_bar_name(self): - for record in self: - if record.cutting_tool_cutterbar_model_id: - self.bar_name = self.cutting_tool_cutterbar_model_id.name - else: - self.bar_name = None - - @api.depends('cutting_tool_cutterbar_model_id') - def _compute_sf_tool_brand_id_3(self): - for record in self: - if record.cutting_tool_cutterbar_model_id: - self.sf_tool_brand_id_3 = self.cutting_tool_cutterbar_model_id.brand_id.id - else: - self.sf_tool_brand_id_3 = None + bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', + domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆')]) + cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting.tool.material', string='刀杆型号', readonly=True) + bar_name = fields.Char('刀杆名称', readonly=True) + sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True) # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=False, - domain=[('cutting_tool_material_id', '=', '刀盘')]) - pad_code = fields.Char('刀盘序列号', readonly=True, compute='_compute_pad_code') - pad_name = fields.Char('刀盘名称', readonly=True, compute='_compute_pad_name') - sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True, - compute='_compute_sf_tool_brand_id_4') - - @api.depends('cutting_tool_cutterpad_model_id') - def _compute_pad_code(self): - for record in self: - if record.cutting_tool_cutterpad_model_id: - self.pad_code = self.cutting_tool_cutterpad_model_id.code - else: - self.pad_code = None - - @api.depends('cutting_tool_cutterpad_model_id') - def _compute_pad_name(self): - for record in self: - if record.cutting_tool_cutterpad_model_id: - self.pad_name = self.cutting_tool_cutterpad_model_id.name - else: - self.pad_name = None - - @api.depends('cutting_tool_cutterpad_model_id') - def _compute_sf_tool_brand_id_4(self): - for record in self: - if record.cutting_tool_cutterpad_model_id: - self.sf_tool_brand_id_4 = self.cutting_tool_cutterpad_model_id.brand_id.id - else: - self.sf_tool_brand_id_4 = None + pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', + domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘')]) + cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting.tool.material', string='刀盘型号', readonly=True) + pad_name = fields.Char('刀盘名称', readonly=True) + sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=False, - domain=[('cutting_tool_material_id', '=', '刀柄')]) - handle_code = fields.Char('刀柄序列号', readonly=True, compute='_compute_handle_code') - handle_name = fields.Char('刀柄名称', readonly=True, compute='_compute_handle_name') - sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True, - compute='_compute_sf_tool_brand_id_5') - - @api.depends('cutting_tool_cutterhandle_model_id') - def _compute_handle_code(self): - for record in self: - if record.cutting_tool_cutterhandle_model_id: - self.handle_code = self.cutting_tool_cutterhandle_model_id.code - else: - self.handle_code = None - - @api.depends('cutting_tool_cutterhandle_model_id') - def _compute_handle_name(self): - for record in self: - if record.cutting_tool_cutterhandle_model_id: - self.handle_name = self.cutting_tool_cutterhandle_model_id.name - else: - self.handle_name = None - - @api.depends('cutting_tool_cutterhandle_model_id') - def _compute_sf_tool_brand_id_5(self): - for record in self: - if record.cutting_tool_cutterhandle_model_id: - self.sf_tool_brand_id_5 = self.cutting_tool_cutterhandle_model_id.brand_id.id - else: - self.sf_tool_brand_id_5 = None + handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', + domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')]) + cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting.tool.material', string='刀柄型号', readonly=True) + handle_name = fields.Char('刀柄名称', readonly=True) + sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=False, - domain=[('cutting_tool_material_id', '=', '夹头')]) - chuck_code = fields.Char('夹头序列号', readonly=True, compute='_compute_chuck_code') - chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_chuck_name') - sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True, - compute='_compute_sf_tool_brand_id_6') + chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', + domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')]) + cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting.tool.material', string='夹头型号', readonly=True) + chuck_name = fields.Char('夹头名称', readonly=True) + sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) - @api.depends('cutting_tool_cutterhead_model_id') - def _compute_chuck_code(self): + @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id') + def _compute_auto_fill(self): for record in self: - if record.cutting_tool_cutterhead_model_id: - self.chuck_code = self.cutting_tool_cutterhead_model_id.code + if record.integral_code_id: + record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_id.id + record.integral_name = record.integral_code_id.product_id.name + record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id else: - self.chuck_code = None - - @api.depends('cutting_tool_cutterhead_model_id') - def _compute_chuck_name(self): - for record in self: - if record.cutting_tool_cutterhead_model_id: - self.chuck_name = self.cutting_tool_cutterhead_model_id.name + record.cutting_tool_integral_model_id = None + record.integral_name = None + record.sf_tool_brand_id_1 = None + if record.blade_code_id: + record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_material_id.id + record.blade_name = record.blade_code_id.product_id.name + record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id else: - self.chuck_name = None - - @api.depends('cutting_tool_cutterhead_model_id') - def _compute_sf_tool_brand_id_6(self): - for record in self: - if record.cutting_tool_cutterhead_model_id: - self.sf_tool_brand_id_6 = self.cutting_tool_cutterhead_model_id.brand_id.id + record.cutting_tool_blade_model_id = None + record.blade_name = None + record.sf_tool_brand_id_2 = None + if record.bar_code_id: + record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_material_id.id + record.bar_name = record.bar_code_id.product_id.name + record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id else: - self.sf_tool_brand_id_6 = None + record.cutting_tool_cutterbar_model_id = None + record.bar_name = None + record.sf_tool_brand_id_3 = None + if record.pad_code_id: + record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_material_id.id + record.pad_name = record.pad_code_id.product_id.name + record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterpad_model_id = None + record.pad_name = None + record.sf_tool_brand_id_4 = None + if record.handle_code_id: + record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_material_id.id + record.handle_name = record.handle_code_id.product_id.name + record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterhandle_model_id = None + record.handle_name = None + record.sf_tool_brand_id_5 = None + if record.chuck_code_id: + record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_material_id.id + record.chuck_name = record.chuck_code_id.product_id.name + record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterhead_model_id = None + record.chuck_name = None + record.sf_tool_brand_id_6 = None coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', default='1') tool_loading_length = fields.Char(string='装刀长') @@ -343,27 +245,27 @@ class FunctionalToolAssemblyOrder(models.TransientModel): """ desc_1 = { 'cutting_tool_integral_model_id': self.cutting_tool_integral_model_id.id, - 'integral_code': self.integral_code, + 'integral_code_id': self.integral_code_id.id, 'integral_name': self.integral_name, 'sf_tool_brand_id_1': self.sf_tool_brand_id_1, 'cutting_tool_blade_model_id': self.cutting_tool_blade_model_id.id, - 'blade_code': self.blade_code, + 'blade_code_id': self.blade_code_id.id, 'blade_name': self.blade_name, 'sf_tool_brand_id_2': self.sf_tool_brand_id_2, 'cutting_tool_cutterbar_model_id': self.cutting_tool_cutterbar_model_id.id, - 'bar_code': self.bar_code, + 'bar_code_id': self.bar_code_id.id, 'bar_name': self.bar_name, 'sf_tool_brand_id_3': self.sf_tool_brand_id_3, 'cutting_tool_cutterpad_model_id': self.cutting_tool_cutterpad_model_id.id, - 'pad_code': self.pad_code, + 'pad_code_id': self.pad_code_id.id, 'pad_name': self.pad_name, 'sf_tool_brand_id_4': self.sf_tool_brand_id_4, 'cutting_tool_cutterhandle_model_id': self.cutting_tool_cutterhandle_model_id.id, - 'handle_code': self.handle_code, + 'handle_code_id': self.handle_code_id.id, 'handle_name': self.handle_name, 'sf_tool_brand_id_5': self.sf_tool_brand_id_5, 'cutting_tool_cutterhead_model_id': self.cutting_tool_cutterhead_model_id.id, - 'chuck_code': self.chuck_code, + 'chuck_code_id': self.chuck_code_id.id, 'chuck_name': self.chuck_name, 'sf_tool_brand_id_6': self.sf_tool_brand_id_6, 'coarse_middle_thin': self.coarse_middle_thin, diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 6398b362..0c85cb66 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -140,58 +140,141 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ From 845d606b365039136b4fe6d63c3b28bc2a45731d Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 23 Oct 2023 17:36:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=BB=84=E8=A3=85=E5=8D=95=E6=89=AB=E6=8F=8F=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/wizard/wizard.py | 28 ++++++++++++++++++++++- sf_tool_management/wizard/wizard_view.xml | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 791f30ac..c9dd4eb9 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -118,6 +118,7 @@ class ToolTransferRequestInformation(models.TransientModel): class FunctionalToolAssemblyOrder(models.TransientModel): _name = 'sf.functional.tool.assembly.order' + _inherit = ["barcodes.barcode_events_mixin"] _description = '功能刀具组装单' # 功能刀具申请信息 @@ -175,9 +176,34 @@ class FunctionalToolAssemblyOrder(models.TransientModel): chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')]) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting.tool.material', string='夹头型号', readonly=True) - chuck_name = fields.Char('夹头名称', readonly=True) + chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) + def on_barcode_scanned(self, barcode): + """ + 智能工厂组装单处扫码绑定刀具物料') + """ + for record in self: + records = record.env['stock.lot'].search([('name', '=', barcode)]) + if not records: + raise ValidationError('扫描的条形码数据不存在,请重新扫描!') + for record_stock_lot in records: + tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name + if tool_material_name == '整体式刀具': + record.integral_code_id = record_stock_lot.id + elif tool_material_name == '刀片': + record.blade_code_id = record_stock_lot.id + elif tool_material_name == '刀杆': + record.bar_code_id = record_stock_lot.id + elif tool_material_name == '刀盘': + record.pad_code_id = record_stock_lot.id + elif tool_material_name == '刀柄': + record.handle_code_id = record_stock_lot.id + elif tool_material_name == '夹头': + record.chuck_code_id = record_stock_lot.id + else: + raise ValidationError('扫描的刀具物料不存在,请重新扫描!') + @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id') def _compute_auto_fill(self): for record in self: diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 0c85cb66..e90599e6 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -141,6 +141,7 @@ +