diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 6aa4c6c3..b5d42f0e 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')) # 产品模型类型