[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) <sle@openerp.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user