From 664ac8128ac3c66dca8119ae2128775c2a14272a Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Fri, 27 Sep 2024 13:32:55 +0800 Subject: [PATCH] =?UTF-8?q?cnc=E6=A0=A1=E9=AA=8C=E5=88=80=E6=97=A0?= =?UTF-8?q?=E6=95=88=E5=88=80=E5=88=9B=E5=BB=BA=E6=A3=80=E6=B5=8B=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=97=B6=E5=85=88=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=AD=98=E5=9C=A8=E5=BE=85=E5=A4=84=E7=90=86?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/mrp_workorder.py | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) 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)