Coalesce boolean account type columns on negative clause

In SQL the negation of NULL is still NULL.

Closes #13967
This commit is contained in:
Cédric Krier
2025-04-11 09:24:13 +02:00
parent 5738a5fb46
commit 5b01323986
2 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
from sql.aggregate import Sum
from sql.conditionals import Coalesce
from trytond import backend
from trytond.i18n import gettext
@@ -109,8 +110,8 @@ class Journal(
account_type = AccountType.__table__()
where = ((move.date >= context.get('start_date'))
& (move.date <= context.get('end_date'))
& ~account_type.receivable
& ~account_type.payable
& ~Coalesce(account_type.receivable, False)
& ~Coalesce(account_type.payable, False)
& (move.company == company.id))
for sub_journals in grouped_slice(journals):
sub_journals = list(sub_journals)
+4 -2
View File
@@ -2221,10 +2221,12 @@ class Reconcile(Wizard):
having=((
Sum(Case((balance > 0, 1), else_=0)) > 0)
& (Sum(Case((balance < 0, 1), else_=0)) > 0)
| Case((account_type.receivable & ~account_type.payable,
| Case((account_type.receivable
& ~Coalesce(account_type.payable, False),
Sum(balance) < 0),
else_=False)
| Case((account_type.payable & ~account_type.receivable,
| Case((account_type.payable
& ~Coalesce(account_type.receivable, False),
Sum(balance) > 0),
else_=False)
)))