[FIX] stock: action_done

There was an issue if you make a backorder for a reserved move while not
having any quantity done on it. The 0 move will have its `picking_id`
field set to the backorder, but not its move lines, and the result was
that a stock move could be considered `assigned` while not having any
move lines.

The test that could show this issue did not fail because of an unwanted
call to `_free_reservation` that would call `_recompute_state` on the
inconsistent stock move.
This commit is contained in:
Simon Lejeune
2017-08-07 11:18:34 +02:00
parent 7a9dd47ae5
commit f55a2aa9df
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -911,6 +911,7 @@ class StockMove(models.Model):
})
picking.message_post('Backorder Created') #message needs to be improved
moves_to_backorder.write({'picking_id': backorder_picking.id})
moves_to_backorder.mapped('move_line_ids').write({'picking_id': backorder_picking.id})
moves_to_backorder.action_assign()
return moves_todo
+1 -1
View File
@@ -295,7 +295,7 @@ class StockMoveLine(models.Model):
rounding = ml.product_uom_id.rounding
# if this move line is force assigned, unreserve elsewhere if needed
if float_compare(ml.qty_done, ml.product_qty, precision_rounding=rounding) > 0:
if ml.location_id.should_impact_quants() and float_compare(ml.qty_done, ml.product_qty, precision_rounding=rounding) > 0:
extra_qty = ml.qty_done - ml.product_qty
ml._free_reservation(ml.product_id, ml.location_id, extra_qty, lot_id=ml.lot_id, package_id=ml.package_id, owner_id=ml.owner_id)
# unreserve what's been reserved