From c8df5ed1794653af65108c57b88c4fbc31cb678c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 20 Dec 2024 14:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E5=A4=96=E5=8D=8F=E5=B7=A5=E5=BA=8F=E9=87=87=E8=B4=AD=E5=8D=95?= =?UTF-8?q?=E5=B7=B2=E5=88=9B=E5=BB=BA=E8=B4=A6=E5=8D=95=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E8=BF=87=E8=B4=A6=EF=BC=8C=E9=80=80=E5=9B=9E=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=8E=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 7bfc0abb..4d8f11df 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -440,6 +440,18 @@ class MrpProduction(models.Model): process_parameters = [] account_moves = [] parameters_not = [] + # 获取原有的工单对应的工序 + origin_designs = self.workorder_ids.technology_design_id + # 获取已删除的工序 + deleted_designs = origin_designs - self.technology_design_ids + if deleted_designs: + for deleted_design in deleted_designs: + workorder = self.env['mrp.workorder'].search([('technology_design_id', '=', deleted_design.id)]) + purchase = workorder._get_surface_technics_purchase_ids() + account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids.ids)]) + if account.state not in ['cancel', False]: + if purchase.name not in account_moves: + account_moves.append(purchase.name) special_design = self.technology_design_ids.filtered( lambda a: a.routing_tag == 'special' and a.is_auto is False) for special in special_design: @@ -451,11 +463,7 @@ class MrpProduction(models.Model): if not product_production_process: if special.process_parameters_id not in process_parameters: process_parameters.append(special.process_parameters_id.display_name) - purchase = self.env['purchase.order'].search([('origin', '=', special.production_id.name)]) - account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids)]) - if account.state not in ['cancel', False]: - if purchase.name not in account_moves: - account_moves.append(purchase.name) + if account_moves: raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves))) if parameters_not: