From 0a4dd5df6ce03be979c6631c33ee9f322ca15f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 19 Mar 2024 09:40:18 +0100 Subject: [PATCH] [FIX] account_financial_report: Filter correctly by account_type in General ledger In v15 it was filtered by the internal_type field (type of account.account.type) to use "other" (most of the accounts had it set). Now in v16, there is the account_type field exists and has to be compatible. The in or not in operator is set to "simplify" the domain and avoid having to set almost all types. --- .../report/general_ledger.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index d7f1c933..a6ec3ba2 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -50,18 +50,19 @@ class GeneralLedgerReport(models.AbstractModel): ) return taxes_data - def _get_account_internal_types(self, grouped_by): - return ( - ["asset_receivable", "liability_payable"] - if grouped_by != "taxes" - else ["other"] - ) + def _get_account_type_domain(self, grouped_by): + """To avoid set all possible types, set in or not in as operator of the types + we are interested in. In v15 we used the internal_type field (type of + account.account.type).""" + at_op = "in" if grouped_by != "taxes" else "not in" + return [ + ("account_type", at_op, ["asset_receivable", "liability_payable"]), + ] def _get_acc_prt_accounts_ids(self, company_id, grouped_by): accounts_domain = [ ("company_id", "=", company_id), - ("account_type", "in", self._get_account_internal_types(grouped_by)), - ] + ] + self._get_account_type_domain(grouped_by) acc_prt_accounts = self.env["account.account"].search(accounts_domain) return acc_prt_accounts.ids @@ -80,8 +81,7 @@ class GeneralLedgerReport(models.AbstractModel): accounts = self.env["account.account"].search(accounts_domain) domain += [("account_id", "in", accounts.ids)] if acc_prt: - internal_types = self._get_account_internal_types(grouped_by) - domain += [("account_type", "in", internal_types)] + domain += self._get_account_type_domain(grouped_by) return domain def _get_initial_balances_pl_ml_domain(