From 010fbb23b09d0343947ded2d920a5bddb60cb014 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 11 Apr 2024 15:11:50 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E6=89=AB=E6=8F=8F=E7=BB=91=E5=AE=9A=E6=89=98=E7=9B=98=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=9D=A1=E4=BB=B6=EF=BC=8C=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E5=9C=A8=E5=B7=A5=E5=8D=95=E5=B7=B2=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=86=8D=E6=89=AB=E6=8F=8F=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=89=98=E7=9B=98=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=AD=E6=8E=A7=E7=9A=84=E5=88=80=E5=85=B7=E7=BB=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E6=94=B9=E4=B8=BA=E4=BC=A0=E8=BE=93=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=B8=85=E5=8D=95=E7=9A=84=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=BB=84=E6=95=B0=E6=8D=AE=EF=BC=9B3=E3=80=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84?= =?UTF-8?q?=E8=A3=85=E5=8D=95=E6=A8=A1=E5=9E=8B=E7=9A=84=E5=88=80=E6=9F=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=88=A0=E9=99=A4=E5=88=80=E6=9F=84?= =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E5=AD=97=E6=AE=B5=EF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=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=B8=A6=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E7=9A=84=E7=B1=BB=E5=9E=8B=E3=80=81?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=BB=84=E3=80=81=E7=9B=B4=E5=BE=84=E3=80=81?= =?UTF-8?q?=E5=88=80=E5=B0=96R=E8=A7=92=E3=80=81=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E5=AF=BF=E5=91=BD=E5=80=BC=E3=80=81=E6=80=BB=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E3=80=81=E4=BC=B8=E5=87=BA=E9=95=BF=E3=80=81=E9=81=BF=E7=A9=BA?= =?UTF-8?q?=E9=95=BF=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=B8=94=E5=8F=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9B6=E3=80=81=E4=BC=98=E5=8C=96=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84=E8=A3=85?= =?UTF-8?q?=E5=8D=95=E5=BC=B9=E7=AA=97=E7=9A=84=E5=B8=83=E5=B1=80=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 6 +- sf_tool_management/controllers/controllers.py | 4 +- sf_tool_management/models/base.py | 21 ++-- sf_tool_management/views/tool_base_views.xml | 4 +- sf_tool_management/wizard/wizard.py | 56 ++++----- sf_tool_management/wizard/wizard_view.xml | 117 +++++++++--------- 6 files changed, 106 insertions(+), 102 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 89510ae0..e7ef0205 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -830,9 +830,9 @@ class SfWorkOrderBarcodes(models.Model): # raise UserError('该托盘已绑定工件,请先解除绑定!!!') if workorder: if workorder.routing_type == '装夹预调': - if workorder.state in ['progress', 'done']: - work_state = {'progress': '进行中', 'done': '已完工'} - raise UserError('该工单%s,不能重新绑定托盘' % work_state.get(workorder.state)) + if workorder.state in ['done']: + work_state = {'done': '已完工'} + raise UserError('装夹%s,请勿重复扫码' % work_state.get(workorder.state)) lots = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)]) if lots: for lot in lots: diff --git a/sf_tool_management/controllers/controllers.py b/sf_tool_management/controllers/controllers.py index 0b003dc6..c8d6ee3f 100644 --- a/sf_tool_management/controllers/controllers.py +++ b/sf_tool_management/controllers/controllers.py @@ -22,14 +22,14 @@ class Manufacturing_Connect(http.Controller): ret = json.loads(datas) # ret = json.loads(ret['result']) logging.info('DeviceId:%s' % ret) - functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([]) + functional_tools = request.env['sf.tool.inventory'].sudo().search([]) res = {'Succeed': True, 'Datas': []} if functional_tools: for item in functional_tools: res['Datas'].append({ 'GroupName': item.tool_groups_id.name, - 'ToolId': item.code, + 'ToolId': item.functional_cutting_tool_model_id.name, 'ToolName': item.name }) except Exception as e: diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 0b444a98..56391077 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -473,26 +473,25 @@ class FunctionalToolAssembly(models.Model): item.pad_product_id = False # ==============刀柄型号============== - handle_freight_barcode = fields.Char('刀柄货位') - handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', compute='_compute_handle_product_id', store=True) + handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_handle_product_id', store=True) + handle_code_id = fields.Many2one('stock.lot', '刀柄序列号') handle_product_id = fields.Many2one('product.product', string='刀柄名称', compute='_compute_handle_product_id', store=True) 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_product_id.cutting_tool_model_id') handle_specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='刀柄规格', - related='handle_code_id.product_id.specification_id') - sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_code_id.product_id.brand_id') + related='handle_product_id.specification_id') + sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', related='handle_product_id.brand_id') - @api.depends('handle_freight_barcode') + @api.depends('handle_code_id') def _compute_handle_product_id(self): for item in self: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.handle_freight_barcode)]) - if location: - item.handle_code_id = location.product_sn_id.id - item.handle_product_id = location.product_id.id + if item.handle_code_id: + item.handle_product_id = item.handle_code_id.product_id.id + item.handle_freight_rfid = item.handle_code_id.rfid else: - item.handle_code_id = False item.handle_product_id = False + item.handle_freight_rfid = False # ==============夹头型号============== chuck_freight_barcode = fields.Char('夹头货位') diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 68b6c9a4..46c77b82 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -589,14 +589,14 @@ - +
- + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 3968a5c4..b6f963f6 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -296,7 +296,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.pad_product_id = False # ================刀柄型号=============== - handle_freight_barcode = fields.Char('刀柄货位', required=True) + handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid') handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True, domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄'), ('tool_material_status', '=', '可用')]) @@ -316,7 +316,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.pad_product_id = False # =================夹头型号============== - chuck_freight_barcode = fields.Char('夹头货位', required=True) + chuck_freight_barcode = fields.Char('夹头货位') chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id', store=True) cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', @@ -345,11 +345,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): for lot_id in lot_ids: if lot_id.quant_ids[-1].location_id.name in '刀具房': record.handle_code_id = lot_id.id - location = self.env['sf.shelf.location'].sudo().search( - [('product_sn_id', '=', lot_id.id)]) - if not location: - raise ValidationError('该刀柄未入库到库位,请先入库!!!') - record.handle_freight_barcode = location.barcode elif lot_id.quant_ids[-1].location_id.name == '刀具组装位置': raise ValidationError('该刀柄已使用,请重新扫描!!!') else: @@ -360,11 +355,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): material_name = location.product_id.cutting_tool_material_id.name if material_name == '夹头': record.chuck_freight_barcode = barcode - elif material_name == '刀柄': - record.handle_freight_barcode = barcode - location = self.env['sf.shelf.location'].sudo().search( - [('barcode', '=', barcode)]) - record.handle_code_id = location.product_sn_id.id elif material_name == '整体式刀具': record.integral_freight_barcode = barcode record.blade_freight_barcode = '' @@ -391,8 +381,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel): for item in self: if item: item.rfid = item.handle_code_id.rfid + item.handle_freight_rfid = item.handle_code_id.rfid else: item.rfid = None + item.handle_freight_rfid = None # 组装功能刀具参数信息 after_name_id = fields.Many2one('sf.tool.inventory', string='功能刀具名称', required=True) @@ -401,8 +393,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): tool_code = fields.Char(string='功能刀具编码', compute='_compute_tool_code') after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True) after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', - string='组装后功能刀具类型', - compute='_compute_after_assembly_functional_tool_type_id') + string='组装后功能刀具类型') after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0') @@ -421,6 +412,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel): after_assembly_effective_length = fields.Float(string='组装后有效长(mm)') L_D_number = fields.Float(string='L/D值(mm)', compute='_compute_l_d_number') hiding_length = fields.Float(string='避空长(mm)') + after_tool_groups_id = fields.Many2one('sf.tool.groups', string='组装后刀具组') + + @api.onchange('after_name_id') + def _onchange_number(self): + for item in self: + if item.after_name_id: + item.after_assembly_functional_tool_diameter = item.after_name_id.diameter + item.after_assembly_knife_tip_r_angle = item.after_name_id.angle + item.after_assembly_max_lifetime_value = item.after_name_id.life_span + item.after_assembly_tool_loading_length = item.after_name_id.tool_length + item.after_assembly_functional_tool_length = item.after_name_id.extension + item.hiding_length = item.after_name_id.blade_length + item.after_assembly_functional_tool_type_id = item.after_name_id.functional_cutting_tool_model_id.id + item.after_tool_groups_id = item.after_name_id.tool_groups_id.id + else: + item.after_assembly_functional_tool_type_id = item.functional_tool_type_id + item.after_tool_groups_id = item.tool_groups_id.id # functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) # res_partner_id = fields.Many2one('res.partner', '智能工厂', domain="[('is_factory', '=', True)]") @@ -489,14 +497,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel): else: obj.after_assembly_knife_tip_r_angle = 0 - @api.depends('functional_tool_type_id') - def _compute_after_assembly_functional_tool_type_id(self): - for obj in self: - if obj.functional_tool_type_id: - obj.after_assembly_functional_tool_type_id = obj.functional_tool_type_id - else: - obj.after_assembly_functional_tool_type_id = None - @api.depends('hiding_length', 'after_assembly_functional_tool_diameter') def _compute_l_d_number(self): for record in self: @@ -567,7 +567,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.env['sf.real.time.distribution.of.functional.tools'].create_or_edit_safety_stock({ 'functional_name_id': self.after_name_id.id, 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, - 'tool_groups_id': self.tool_groups_id.id, + 'tool_groups_id': self.after_tool_groups_id.id, 'diameter': self.after_assembly_functional_tool_diameter, 'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, 'coarse_middle_thin': self.after_assembly_coarse_middle_thin, @@ -607,12 +607,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'barcode_id': stock_lot.id, 'code': self.tool_code, 'rfid': self.rfid, - 'tool_groups_id': self.tool_groups_id.id, + 'tool_groups_id': self.after_tool_groups_id.id, 'integral_freight_barcode': self.integral_freight_barcode, 'blade_freight_barcode': self.blade_freight_barcode, 'bar_freight_barcode': self.bar_freight_barcode, 'pad_freight_barcode': self.pad_freight_barcode, - 'handle_freight_barcode': self.handle_freight_barcode, + 'handle_code_id': self.handle_code_id.id, 'chuck_freight_barcode': self.chuck_freight_barcode, 'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name, @@ -645,7 +645,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'code': self.tool_code, 'name': self.after_assembly_functional_tool_name, 'rfid': self.rfid, - 'tool_groups_id': self.tool_groups_id.id, + 'tool_groups_id': self.after_tool_groups_id.id, 'functional_tool_name_id': functional_tool_assembly_id.id, 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, 'cutting_tool_integral_model_id': self.integral_product_id.id, @@ -707,7 +707,7 @@ class StockPicking(models.Model): 'code': obj.tool_code, 'rfid': obj.rfid, 'functional_tool_name': obj.after_assembly_functional_tool_name, - 'tool_groups_id': obj.tool_groups_id.id + 'tool_groups_id': obj.after_tool_groups_id.id }) # 将刀具组装入库单的状态更改为就绪 picking_id.action_confirm() @@ -840,7 +840,7 @@ class StockLot(models.Model): 'code': '' if not obj else obj.tool_code, 'rfid': '' if not obj else obj.rfid, 'functional_tool_name': '' if not obj else obj.after_assembly_functional_tool_name, - 'tool_groups_id': False if not obj else obj.tool_groups_id.id + 'tool_groups_id': False if not obj else obj.after_tool_groups_id.id }) return stock_move_id, stock_move_line_id diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 7222d9c9..386c8d7c 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -200,6 +200,31 @@ + +
+ +
+ + + + + + + + + + + + + + + + + + +
@@ -283,33 +308,6 @@ - -
- -
- - - - - - - - - - - - - - - - - - - - -
@@ -334,37 +332,44 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + +