details:   https://code.tryton.org/tryton/commit/a483e2e8d1bf
branch:    7.4
user:      Cédric Krier <[email protected]>
date:      Tue Nov 25 18:38:51 2025 +0100
description:
        Round moved quantity before compare to 0

        As moved quantity is the sum of float, it may carry rounding issue so 
it must
        be rounded before comparison.

        Closes #14386
        (grafted from 760368f8aa28083ad69311ce0f424c0de3d54b3d)
diffstat:

 modules/purchase/purchase.py |  2 +-
 modules/sale/sale.py         |  2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r 5723fcbb3599 -r a483e2e8d1bf modules/purchase/purchase.py
--- a/modules/purchase/purchase.py      Wed Nov 19 00:27:21 2025 +0100
+++ b/modules/purchase/purchase.py      Tue Nov 25 18:38:51 2025 +0100
@@ -2030,7 +2030,7 @@
         quantity = (
             self._get_move_quantity(move_type)
             - self._get_shipped_quantity(move_type))
-        if quantity < 0:
+        if self.unit.round(quantity) < 0:
             warning_name = Warning.format(
                 'check_move_quantity', [self])
             if Warning.check(warning_name):
diff -r 5723fcbb3599 -r a483e2e8d1bf modules/sale/sale.py
--- a/modules/sale/sale.py      Wed Nov 19 00:27:21 2025 +0100
+++ b/modules/sale/sale.py      Tue Nov 25 18:38:51 2025 +0100
@@ -2073,7 +2073,7 @@
         quantity = (
             self._get_move_quantity(move_type)
             - self._get_shipped_quantity(move_type))
-        if quantity < 0:
+        if self.unit.round(quantity) < 0:
             warning_name = Warning.format(
                 'check_move_quantity', [self])
             if Warning.check(warning_name):

Reply via email to