diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8c2ffada..66ab3183 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -381,6 +381,10 @@ 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']: + production.state = 'done' + # 退回调整 def technology_back_adjust(self): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 6506cc1a..8c202e6f 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -672,8 +672,8 @@ class StockPicking(models.Model): 'partner_id': self.partner_id.id, }) move_dest_id = False - # 如果当前工单是是制造订单的最后一个工单 - if workorder == item.workorder_ids[-1]: + # 如果当前工单是是制造订单的最后一个工艺外协工单 + if workorder == next((workorder for workorder in reversed(item.workorder_ids) if workorder.is_subcontract), None): move_dest_id = item.move_raw_ids[0].id else: # 从sorted_workorders中找到上一工单的move diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 567930dd..8a44b621 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -131,11 +131,6 @@ - -