From 77815c45a0519967fcaecb1ef3093c052897f0d8 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 11 Jul 2024 16:37:20 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=BD=93=E6=A3=80=E6=B5=8B=E5=88=B0?= =?UTF-8?q?=E7=BC=BA=E5=88=80=E5=B7=A5=E5=8D=95=E9=9C=80=E8=A6=81=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E4=BB=8E=E5=88=80=E5=85=B7?= =?UTF-8?q?=E6=88=BF=E5=87=BA=E5=BA=93=E5=88=B0=E7=BA=BF=E8=BE=B9=E5=88=80?= =?UTF-8?q?=E6=9E=B6=E6=97=B6=EF=BC=8C=E6=9B=B4=E6=94=B9cnc=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E5=8D=95=E7=9A=84=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=BA=E6=AD=A3=E5=B8=B8=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 4 ++-- sf_manufacturing/models/mrp_workorder.py | 2 ++ sf_tool_management/models/functional_tool.py | 15 +++++++++++++++ sf_tool_management/models/mrp_workorder.py | 2 -- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 0b4da7cc..0c3ab335 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -32,9 +32,9 @@ class MrpProduction(models.Model): def _compute_tool_state(self): for item in self: if item: - if item.workorder_ids.filtered(lambda a: a.tool_state == '2'): + if item.workorder_ids.filtered(lambda a: a.tool_state == '2' and a.state not in ('rework', '返工')): item.tool_state = '2' - elif item.workorder_ids.filtered(lambda a: a.tool_state == '1'): + elif item.workorder_ids.filtered(lambda a: a.tool_state == '1' and a.state not in ('rework', '返工')): item.tool_state = '1' else: item.tool_state = '0' diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 4fefc154..944bf402 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1135,6 +1135,8 @@ class CNCprocessing(models.Model): program_path = fields.Char('程序文件路径') program_create_date = fields.Datetime('程序创建日期') + tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='刀具状态', default='0') + # mrs下发编程单创建CNC加工 def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp): cnc_processing = None diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 4e791fe5..4138bfe3 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -115,6 +115,8 @@ class FunctionalCuttingToolEntity(models.Model): # 新刀入库到线边 item.create_stock_move(pre_manufacturing_id, location_id) item.current_shelf_location_id = location_id.id + # 对该刀进行校验(校验是否为制造订单所缺的刀) + item.cnc_function_tool_use_verify() # 中控反馈该位置没有刀 else: @@ -255,6 +257,15 @@ class FunctionalCuttingToolEntity(models.Model): result['domain'] = [('id', '=', self.safe_inventory_id.id)] return result + def cnc_function_tool_use_verify(self): + """ + cnc程序用刀可用校验 + """ + cnc_processing_ids = self.env['sf.cnc.processing'].search( + [('tool_state', '=', '1'), ('cutting_tool_name', '=', self.tool_name_id.name)]) + if cnc_processing_ids: + cnc_processing_ids.sudo().write({'tool_state': '0'}) + def tool_inventory_displacement_out(self): """ 机床当前刀库实时信息接口,功能刀具出库 @@ -265,6 +276,10 @@ class FunctionalCuttingToolEntity(models.Model): self.create_stock_move(stock_location_id, False) self.current_location_id = stock_location_id.id self.current_shelf_location_id = False + + if self.current_location_id.name == '刀具房': + # 对该刀进行校验(校验是否为制造订单所缺的刀) + self.cnc_function_tool_use_verify() # self.barcode_id.create_stock_quant(location_inventory_id, stock_location_id, # self.functional_tool_name_id.id, '机床装刀', self.functional_tool_name_id, # self.functional_tool_name_id.tool_groups_id) diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index a2886add..f3476864 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -10,8 +10,6 @@ class CNCprocessing(models.Model): _inherit = 'sf.cnc.processing' _description = 'CNC加工用刀检测' - tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='刀具状态', default='0') - # ==========MES装刀指令接口========== # def register_cnc_processing(self, knife_plan): # config = self.env['res.config.settings'].get_values()