diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 27baa7be..0bbda373 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -50,6 +50,7 @@ class MrpProduction(models.Model): def _compute_tool_state(self): 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'): item.tool_state = '2' @@ -57,6 +58,10 @@ class MrpProduction(models.Model): item.tool_state = '1' else: item.tool_state = '0' + if tool_state == '2' and item.tool_state != '2': + item.detection_result_ids.filtered( + lambda a: a.detailed_reason == '无效功能刀具' and a.handle_result == '待处理').write( + {'handle_result': '已处理'}) # state = fields.Selection(selection_add=[ # ('pending_scheduling', '待排程'), diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 352162b7..f3fc3484 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -105,6 +105,12 @@ class CNCprocessing(models.Model): 'test_results': '返工', 'handle_result': '待处理' }) + if not production_id.is_rework: + production_id.write({ + 'is_rework': True + }) + production_id.workorder_ids.filtered( + lambda a: a.processing_panel == key and not a.is_rework).write({'is_rework': True}) # 对缺刀信息进行处理 for key in data2: if data2.get(key):