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

        issue9664
        review328231002
        (grafted from c21747a2ee8454812ecf5f8e1592a520225e8c20)
diffstat:

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

diffs (13 lines):

diff -r cbfa7a6a48ef -r 76648eff51e3 move.py
--- a/move.py   Wed Sep 16 14:34:27 2020 +0200
+++ b/move.py   Wed Oct 21 23:33:28 2020 +0200
@@ -66,6 +66,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