[FIX] stock_account: round quantities to UoM precision when updating moves
Have a product P values in FIFO, create an incoming stock move. Suppose P has UoM U with rounding R, and the stock move has quantity Q. Edit the quantity done to be Q + e, with e << R. By the semantic of the UoM rounding, this should mean that no change has been done. However no such check was done, so the move was updated. As a result, this would mess up the valuation of P. opw 2006831
This commit is contained in:
@@ -88,7 +88,10 @@ class StockMoveLine(models.Model):
|
||||
if 'qty_done' in vals:
|
||||
moves_to_update = {}
|
||||
for move_line in self.filtered(lambda ml: ml.state == 'done' and (ml.move_id._is_in() or ml.move_id._is_out())):
|
||||
moves_to_update[move_line.move_id] = vals['qty_done'] - move_line.qty_done
|
||||
rounding = move_line.product_uom_id.rounding
|
||||
qty_difference = float_round(vals['qty_done'] - move_line.qty_done, precision_rounding=rounding)
|
||||
if not float_is_zero(qty_difference, precision_rounding=rounding):
|
||||
moves_to_update[move_line.move_id] = qty_difference
|
||||
|
||||
for move_id, qty_difference in moves_to_update.items():
|
||||
move_vals = {}
|
||||
|
||||
Reference in New Issue
Block a user