details:   https://code.tryton.org/tryton/commit/06439e7a04b3
branch:    7.0
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 eda14099dc6d -r 06439e7a04b3 modules/purchase/purchase.py
--- a/modules/purchase/purchase.py      Wed Dec 03 08:47:20 2025 +0100
+++ b/modules/purchase/purchase.py      Tue Nov 25 18:38:51 2025 +0100
@@ -1879,7 +1879,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 eda14099dc6d -r 06439e7a04b3 modules/sale/sale.py
--- a/modules/sale/sale.py      Wed Dec 03 08:47:20 2025 +0100
+++ b/modules/sale/sale.py      Tue Nov 25 18:38:51 2025 +0100
@@ -1917,7 +1917,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