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( diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index d79425de..d31a859f 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -126,7 +126,7 @@ class PurchaseOrder(models.Model): if not work_ids: continue min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence) - if min_sequence_wk.is_subcontract: + if min_sequence_wk.is_subcontract and min_sequence_wk.state == 'ready': picking_id = production_id.picking_ids.filtered( lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区') move_out = picking_id.move_ids