details:   https://code.tryton.org/tryton/commit/ff085e946456
branch:    8.0
user:      Cédric Krier <[email protected]>
date:      Fri Oct 09 23:25:45 2026 +0200
description:
        Cast currency rounding when comparing against sum of debit - credit for 
SQLite

        The Decimal value is adapted as string for SQLite backend so without 
column
        affinity to trigger conversion, SQLite compares REAL against TEXT. And 
for
        SQLite's comparison ordering, numeric values sort before text values.

        Closes #15158
        (grafted from 5c67a5358f10ebc9192f680acdc9e61b976719fc)
diffstat:

 modules/account/move.py |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r f8a8aedcdecc -r ff085e946456 modules/account/move.py
--- a/modules/account/move.py   Wed Sep 23 10:41:33 2026 +0200
+++ b/modules/account/move.py   Fri Oct 09 23:25:45 2026 +0200
@@ -355,9 +355,11 @@
         '''
         pool = Pool()
         MoveLine = pool.get('account.move.line')
+        Currency = pool.get('currency.currency')
         line = MoveLine.__table__()
         transaction = Transaction()
         cursor = transaction.connection.cursor()
+        cast = Currency.rounding.sql_cast
 
         for company, moves in groupby(moves, key=lambda m: m.company):
             currency = company.currency
@@ -370,7 +372,7 @@
                 group_by=line.move,
                 having=Abs(Round(
                         Sum(line.debit - line.credit),
-                        currency.digits)) < abs(currency.rounding))
+                        currency.digits)) < cast(abs(currency.rounding)))
             cursor.execute(*line.update(
                     [line.state],
                     ['valid'],
@@ -382,7 +384,7 @@
                 group_by=line.move,
                 having=Abs(Round(
                         Sum(line.debit - line.credit),
-                        currency.digits)) >= abs(currency.rounding))
+                        currency.digits)) >= cast(abs(currency.rounding)))
             cursor.execute(*line.update(
                     [line.state],
                     ['draft'],

Reply via email to