From 04fbaf4e056752db72158397e417af520c838ea3 Mon Sep 17 00:00:00 2001 From: Bernat Brunet Date: Thu, 15 Oct 2020 10:04:42 +0200 Subject: [PATCH] Update fifo quantity calculation. Backport from master --- fifo_quantity_round.diff | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fifo_quantity_round.diff b/fifo_quantity_round.diff index 7b644ed..b158edb 100644 --- a/fifo_quantity_round.diff +++ b/fifo_quantity_round.diff @@ -1,13 +1,14 @@ diff --git a/move.py b/move.py -index 94fa17d..7e4d733 100644 +index 1b41353..85c89eb 100644 --- a/trytond/trytond/modules/product_cost_fifo/move.py +++ b/trytond/trytond/modules/product_cost_fifo/move.py -@@ -63,7 +63,7 @@ class Move(metaclass=PoolMeta): - cost_price += move_unit_price * Decimal(str(move_qty)) - +@@ -105,6 +105,9 @@ class Move(metaclass=PoolMeta): move_qty = Uom.compute_qty(self.product.default_uom, move_qty, -- move.uom, round=False) -+ move.uom, round=True) + move.uom, round=False) move.fifo_quantity = (move.fifo_quantity or 0.0) + move_qty ++ # Due to float, the fifo quantity result can exceed the quantity. ++ assert move.quantity >= move.fifo_quantity - move.uom.rounding ++ move.fifo_quantity = min(move.fifo_quantity, move.quantity) to_save.append(move) if to_save: + # TODO save in do method when product change