From 5b61a801c5a60188a8430835384ebdefd939aa44 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Wed, 14 May 2025 13:57:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A9=BA=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 4180bcce..011482d9 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1383,7 +1383,16 @@ class ResMrpWorkOrder(models.Model): boolean = True if not boolean: raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) - self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name + self.pro_code = False # 默认值 + if ( + self.production_id + and self.production_id.move_raw_ids + and len(self.production_id.move_raw_ids) > 0 + and self.production_id.move_raw_ids[0].move_line_ids + and len(self.production_id.move_raw_ids[0].move_line_ids) > 0 + and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id + ): + self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name # cnc校验 if self.production_id.production_type == '自动化产线加工': cnc_workorder = self.search(