diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 9f7c6d4dfd7..ddcb4853653 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1178,7 +1178,9 @@ class MrpProduction(models.Model): self.move_raw_ids._trigger_scheduler() self.picking_ids.filtered( lambda p: p.state not in ['cancel', 'done']).action_confirm() - self.state = 'confirmed' + # Force confirm state only for draft production not for more advanced state like + # 'progress' (in case of backorders with some qty_producing) + self.filtered(lambda mo: mo.state == 'draft').state = 'confirmed' return True def action_assign(self): @@ -1518,7 +1520,6 @@ class MrpProduction(models.Model): # Remove the serial move line without reserved quantity. Post inventory will assigned all the non done moves # So those move lines are duplicated. backorders.move_raw_ids.move_line_ids.filtered(lambda ml: ml.product_id.tracking == 'serial' and ml.product_qty == 0).unlink() - backorders.move_raw_ids._recompute_state() for old_wo, wo in zip(self.workorder_ids, backorders.workorder_ids): wo.qty_produced = max(old_wo.qty_produced - old_wo.qty_producing, 0) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 1bb5fe23c1c..c928c7af007 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1747,7 +1747,7 @@ class StockMove(models.Model): else: moves_state_to_write['confirmed'].add(move.id) for state, moves_ids in moves_state_to_write.items(): - self.browse(moves_ids).write({'state': state}) + self.browse(moves_ids).filtered(lambda m: m.state != state).state = state @api.model def _consuming_picking_types(self):