diff --git a/modules/account/journal.py b/modules/account/journal.py index f28bea762d..e1e09d0783 100644 --- a/modules/account/journal.py +++ b/modules/account/journal.py @@ -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) diff --git a/modules/account/move.py b/modules/account/move.py index 8e1114cdc4..14febc243b 100644 --- a/modules/account/move.py +++ b/modules/account/move.py @@ -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) )))