From 403e64a9570ecb4d2b9f73b2e1336ce730e789e0 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 6 Jan 2025 11:09:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E9=9D=A2=E5=B7=A5=E8=89=BA=E5=A4=96?= =?UTF-8?q?=E5=8D=8F=E5=85=B3=E8=81=94=E9=87=87=E8=B4=AD=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 31 +++++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 8b34feb8..447c6da1 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -330,7 +330,7 @@ class ResMrpWorkOrder(models.Model): return result def _get_surface_technics_purchase_ids(self): - domain = [('origin', '=', self.production_id.name), ('purchase_type', '=', 'consignment')] + domain = [('origin', 'like', '%' + self.production_id.name + '%'), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) purchase_orders_id = self.env['purchase.order'] for po in purchase_orders: @@ -1058,16 +1058,18 @@ class ResMrpWorkOrder(models.Model): and workorder.production_id.schedule_state == '已排' and len(workorder.production_id.picking_ids.filtered( lambda w: w.state not in ['done', 'cancel'])) == 0): + workorder.state = 'ready' if workorder.is_subcontract is True: purchase_orders_id = self._get_surface_technics_purchase_ids() if purchase_orders_id.state == 'purchase': - workorder.state = 'ready' + move_out = workorder.move_subcontract_workorder_ids[1] + for mo in move_out: + if mo.state != 'done': + mo.write({'state': 'assigned', 'production_id': False}) continue - else: - workorder.state = 'waiting' - continue - else: - workorder.state = 'ready' + continue + else: + workorder.state = 'waiting' continue # ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]========================== if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework' @@ -1076,7 +1078,7 @@ class ResMrpWorkOrder(models.Model): if workorder.state != 'waiting': workorder.state = 'waiting' continue - if workorder.production_id.programming_state == '已编程' and workorder.technology_design_id.routing_tag != 'special': + if workorder.production_id.programming_state == '已编程': workorder.state = 'ready' elif workorder.state != 'waiting': workorder.state = 'waiting' @@ -1091,12 +1093,17 @@ class ResMrpWorkOrder(models.Model): if workorder.is_subcontract is False: workorder.state = 'ready' else: + if len(workorder.production_id.picking_ids.filtered( + lambda w: w.state not in ['done', + 'cancel'])) == 0 and workorder.production_id.programming_state == '已编程': + workorder.state = 'ready' purchase_orders_id = self._get_surface_technics_purchase_ids() if purchase_orders_id: - workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting' - else: - workorder.state = 'waiting' - + if purchase_orders_id.state == 'purchase': + move_out = workorder.move_subcontract_workorder_ids[1] + for mo in move_out: + if mo.state != 'done': + mo.write({'state': 'assigned', 'production_id': False}) # 重写工单开始按钮方法 def button_start(self):