From c4005532949f9266b52b88cbf2e67cbe5c262a2a Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 25 Feb 2025 16:35:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E7=A1=AE=E8=AE=A4=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=8D=95=E7=A9=BA=E5=80=BC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizard/production_technology_wizard.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index 0415d1fd..66d7ea8d 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -3,6 +3,7 @@ import logging from itertools import groupby from odoo import models, api, fields, _ +from odoo.exceptions import UserError class ProductionTechnologyWizard(models.TransientModel): @@ -88,7 +89,10 @@ class ProductionTechnologyWizard(models.TransientModel): for item in productions: workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted( key=lambda a: a.sequence) - if workorder[0].state in ['pending']: - if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程': - workorder[0].state = 'waiting' + first_element = workorder[0] if workorder else None + if not first_element: + raise UserError('工艺确认后,工单未生成,请检查配置') + if first_element.state in ['pending']: + if first_element.production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程': + first_element.state = 'waiting' return productions