diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 66ab3183..a7e9398c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -381,8 +381,8 @@ class MrpProduction(models.Model): # 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工 if production.tool_state == '2': production.state = 'rework' - if all(wo_state in ('done', 'rework', 'cancel') for wo_state in production.workorder_ids.mapped('state')): - if production.state not in ['scrap', 'rework']: + if production.workorder_ids and all(wo_state in ('done', 'rework', 'cancel') for wo_state in production.workorder_ids.mapped('state')): + if production.state not in ['scrap', 'rework', 'cancel']: production.state = 'done'