diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 6eff353d..e4dfb2a8 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -36,12 +36,15 @@ 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_remark) + workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel']) + if workorder_ids.filtered(lambda a: a.tool_state == '1'): + work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1') tool_state_remark = '' for work_id in work_ids: - tool_state_remark = f"{work_id.tool_state_remark}\n" + 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}" item.tool_state_remark = tool_state_remark else: item.tool_state_remark = False @@ -51,7 +54,7 @@ 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', '返工')) + workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel']) if workorder_ids.filtered(lambda a: a.tool_state == '2'): item.tool_state = '2' elif workorder_ids.filtered(lambda a: a.tool_state == '1'):