From 566c459a152e9d9d9b5ec4c40da7b768f6ccaa87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 1 Aug 2016 21:02:03 +0200 Subject: [PATCH] Round written quantity in ShipmentOut._sync_inventory_to_outgoing Even with only subtraction, the result quantity may have rounding issue. issue5754 review27521002 --- stock.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stock.py b/stock.py index d0a522c0d9..ac7e578ab5 100644 --- a/stock.py +++ b/stock.py @@ -147,13 +147,14 @@ class ShipmentOut: values = {} if quantity < out_quantity: outgoing_moves.extend(Move.copy([out_move], default={ - 'quantity': out_quantity - quantity, + 'quantity': out_move.uom.round( + out_quantity - quantity), })) - values['quantity'] = quantity + values['quantity'] = out_move.uom.round(quantity) values['lot'] = move.lot.id to_write.extend(([out_move], values)) quantity -= out_quantity - assert quantity <= 0 + assert move.uom.round(quantity) <= 0 if to_write: Move.write(*to_write)