diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 965fa03c..ce63c25d 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -95,16 +95,20 @@ class CNCprocessing(models.Model): # tool_state_remark1 = f'{key}无效刀:{data1.get(key)}' # 无效刀处理逻辑 # 1、创建制造订单无效刀检测结果记录 - logging.info('创建制造订单无效刀检测结果记录!') - production_id.detection_result_ids.create({ - 'production_id': production_id.id, - 'processing_panel': key, - 'routing_type': 'CNC加工', - 'rework_reason': 'programming', # 原因:编程(programming) - 'detailed_reason': '无效功能刀具', - 'test_results': '返工', - 'handle_result': '待处理' - }) + if not production_id.detection_result_ids.filtered( + lambda a: (a.processing_panel == key and a.detailed_reason == '无效功能刀具' + and a.handle_result == '待处理' and a.routing_type == 'CNC加工' + and a.rework_reason == 'programming' and a.test_results == '返工')): + logging.info('创建制造订单无效刀检测结果记录!') + production_id.detection_result_ids.create({ + 'production_id': production_id.id, + 'processing_panel': key, + 'routing_type': 'CNC加工', + 'rework_reason': 'programming', # 原因:编程(programming) + 'detailed_reason': '无效功能刀具', + 'test_results': '返工', + 'handle_result': '待处理' + }) # 修改当前面装夹预调工单的 is_rework 为 True # work_ids = production_id.workorder_ids.filtered( # lambda a: a.routing_type == '装夹预调' and a.processing_panel == key and not a.is_rework)