diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 3f48a5644b5..8146f84650f 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -199,6 +199,12 @@ class StockMoveLine(models.Model): mls = super(StockMoveLine, self).create(vals_list) for ml in mls: + if ml.move_id and \ + ml.move_id.picking_id and \ + ml.move_id.picking_id.immediate_transfer and \ + ml.move_id.state != 'done' and \ + 'qty_done' in vals: + ml.move_id.product_uom_qty = ml.move_id.quantity_done if ml.state == 'done': if 'qty_done' in vals: ml.move_id.product_uom_qty = ml.move_id.quantity_done @@ -347,7 +353,7 @@ class StockMoveLine(models.Model): # done stock move should have its `quantity_done` equals to its `product_uom_qty`, and # this is what move's `action_done` will do. So, we replicate the behavior here. if updates or 'qty_done' in vals: - moves = self.filtered(lambda ml: ml.move_id.state == 'done').mapped('move_id') + moves = self.filtered(lambda ml: ml.move_id.state == 'done' or ml.move_id.picking_id and ml.move_id.picking_id.immediate_transfer).mapped('move_id') for move in moves: move.product_uom_qty = move.quantity_done next_moves._do_unreserve()