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
This commit is contained in:
Cédric Krier committed 2026-10-09 23:25:45 +02:00
1 parent 37c0dd9d7c
commit a9448b7ec8
1 file changed
+4 -2
+4 -2
View File
@@ -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'],