From 8303b1a69e96807bcb548ef079dcb463e34df36b Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Mon, 30 Sep 2019 13:47:46 +0000 Subject: [PATCH] [FIX] stock: immediate transfers in the future Immediate transfers only fill the quantity done of stock moves/stock move lines Those transfer are thus not taken into account for the forecast computation if they are not validated. Indeed, the stock quant are not yet updated and the initial demand is left blank. This commit duplicate the quantity done of immediate transfer on their initial demand this quantity is still hidden in the view but can now enter in the forecast quantity. closes odoo/odoo#38169 Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_move_line.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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()