From a9448b7ec85133effe1870b2b51617d3b48cb86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 9 Oct 2026 23:25:45 +0200 Subject: [PATCH] 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) --HG-- branch : 8.0 --- modules/account/move.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/account/move.py b/modules/account/move.py index 594a587f7d..8263aa3ca5 100644 --- a/modules/account/move.py +++ b/modules/account/move.py @@ -355,9 +355,11 @@ class Move(DescriptionOriginMixin, ModelSQL, ModelView): ''' 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 @@ class Move(DescriptionOriginMixin, ModelSQL, ModelView): 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 @@ class Move(DescriptionOriginMixin, ModelSQL, ModelView): 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'],