From dda627f20aaebe3117be8b081e647f71a728c028 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 11 Nov 2024 16:38:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=B7=A5=E5=BA=8F=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=96=B9=E6=B3=95=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index fa81837f..4677d744 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -690,6 +690,41 @@ class MrpProduction(models.Model): return True def _reset_work_order_sequence(self): + """ + 工单工序排序方法(新) + """ + for rec in self: + workorder_ids = rec.workorder_ids + technology_design_ids = rec.technology_design_ids + if workorder_ids.filtered(lambda item: item.state in ('返工', 'rework')): + # 获取返工后新生成的工单 + work_ids = workorder_ids.filtered(lambda item: item.sequence == 0) + # 对工单进行逐个插入 + for work_id in work_ids: + for order_id in rec.workorder_ids.filtered(lambda item: item.sequence > 0): + if work_id.name == order_id.name: + work_id.sequence = order_id.sequence + 1 + break + # 对该工单之后的工单工序进行加一 + work_order_ids = rec.workorder_ids.filtered(lambda item: item.sequence >= work_id.sequence) + for work in work_order_ids: + work.sequence = work.sequence + 1 + + else: + # 将工艺设计生成的工单序号赋值给工单的序号 + for work in workorder_ids: + td_ids = technology_design_ids.filtered( + lambda item: (item.route_id.name in work.name and item.process_parameters_id + and item.process_parameters_id == work.surface_technics_parameters_id) or + (item.route_id.name == work.name and item.panel + and item.panel == work.processing_panel)) + if td_ids: + work.sequence = td_ids[0].sequence + + def _reset_work_order_sequence_1(self): + """ + 工单工序排序方法(旧) + """ for rec in self: workorder_ids = rec.workorder_ids.filtered(lambda item: item.state in ('返工', 'rework')) # 产品模型类型