changeset c21747a2ee84 in modules/product_cost_fifo:default
details: 
https://hg.tryton.org/modules/product_cost_fifo?cmd=changeset;node=c21747a2ee84
description:
        Do not set fifo_quantity greater than quantity

        issue9664
        review328231002
diffstat:

 move.py |  3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diffs (13 lines):

diff -r ee239acea618 -r c21747a2ee84 move.py
--- a/move.py   Fri Oct 16 19:19:57 2020 +0200
+++ b/move.py   Wed Oct 21 23:33:28 2020 +0200
@@ -85,6 +85,9 @@
             move_qty = Uom.compute_qty(self.product.default_uom, move_qty,
                     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

Reply via email to