From a81ad08740213c72e1d9871bb14a0eaf51a10ffb Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 29 Jul 2024 16:43:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=9F=E8=83=BD=E5=88=80?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 25 +++++++---------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index b99d1b25..6eff353d 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -36,17 +36,12 @@ class MrpProduction(models.Model): def _compute_tool_state_remark(self): for item in self: if item.workorder_ids: - work_ids = [] - for workorder_id in item.workorder_ids: - if workorder_id.tool_state == '1': - work_ids.append(workorder_id) - if work_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_remark) tool_state_remark = '' for work_id in work_ids: - if tool_state_remark == '': - tool_state_remark = f"{work_id.tool_state_remark}" - else: - tool_state_remark = f"{tool_state_remark}\n{work_id.tool_state_remark}" + tool_state_remark = f"{work_id.tool_state_remark}\n" item.tool_state_remark = tool_state_remark else: item.tool_state_remark = False @@ -56,16 +51,10 @@ class MrpProduction(models.Model): for item in self: if item.workorder_ids: tool_state = item.tool_state - 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: + workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工')) + if workorder_ids.filtered(lambda a: a.tool_state == '2'): item.tool_state = '2' - elif work_ids_1: + elif workorder_ids.filtered(lambda a: a.tool_state == '1'): item.tool_state = '1' else: item.tool_state = '0'