From 639dd4e78daa670ef498453d2f4b4914eb431f39 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 29 Jul 2024 11:32:33 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A4=84=E7=90=86=E5=A4=A7=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E4=BF=AE=E6=94=B9cnc=E7=BC=96=E7=A8=8B=E5=8D=95?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E9=80=92=E5=BD=92=E8=80=8C=E4=BA=A7=E7=94=9F=E7=9A=84?= =?UTF-8?q?=E6=A0=88=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 20 ++++++++++++++------ sf_manufacturing/models/mrp_workorder.py | 2 +- sf_tool_management/models/functional_tool.py | 11 ++++++++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index e6668ecf..b99d1b25 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -36,9 +36,11 @@ class MrpProduction(models.Model): def _compute_tool_state_remark(self): for item in self: if item.workorder_ids: - workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工')) - if workorder_ids.filtered(lambda a: a.tool_state_remark): - work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1' and a.state not in ['rework']) + work_ids = [] + for workorder_id in item.workorder_ids: + if workorder_id.tool_state == '1': + work_ids.append(workorder_id) + if work_ids: tool_state_remark = '' for work_id in work_ids: if tool_state_remark == '': @@ -54,10 +56,16 @@ class MrpProduction(models.Model): for item in self: if item.workorder_ids: tool_state = item.tool_state - workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工')) - if workorder_ids.filtered(lambda a: a.tool_state == '2'): + work_ids_1 = [] + work_ids_2 = [] + for workorder_id in item.workorder_ids: + if workorder_id.tool_state == '2': + work_ids_2.append(workorder_id) + elif workorder_id.tool_state == '1': + work_ids_1.append(workorder_id) + if work_ids_2: item.tool_state = '2' - elif workorder_ids.filtered(lambda a: a.tool_state == '1'): + elif work_ids_1: 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 44c019eb..65f85048 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -194,7 +194,7 @@ class ResMrpWorkOrder(models.Model): for cnc_id in cnc_ids: if cnc_id.cutting_tool_name not in tool_state_remark: tool_state_remark.append(cnc_id.cutting_tool_name) - item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}]" + item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}" else: item.tool_state_remark = None diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index dd539fc2..0d9473ca 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -263,8 +263,17 @@ class FunctionalCuttingToolEntity(models.Model): if self.tool_name_id.name: cnc_processing_ids = self.env['sf.cnc.processing'].search( [('tool_state', '=', '1'), ('cutting_tool_name', '=', self.tool_name_id.name)]) + production_ids = [] if cnc_processing_ids: - cnc_processing_ids.sudo().write({'tool_state': '0'}) + for item in cnc_processing_ids: + if item.workorder_id and item.workorder_id.production_id not in production_ids: + production_ids.append(item.workorder_id.production_id) + if production_ids: + # 对同一制造订单的工单的cnc编程单的功能刀具状态进行变更,并调用工单的功能刀具状态计算方法 + for production_id in production_ids: + cnc_ids = cnc_processing_ids.filtered(lambda a: a.workorder_id.production_id == production_id) + cnc_ids.sudo().write({'tool_state': '0'}) + cnc_ids.workorder_id._compute_tool_state() def tool_inventory_displacement_out(self): """