diff --git a/account_financial_report/report/templates/trial_balance.xml b/account_financial_report/report/templates/trial_balance.xml index 934c1e6ff..99fb1d6e9 100644 --- a/account_financial_report/report/templates/trial_balance.xml +++ b/account_financial_report/report/templates/trial_balance.xml @@ -134,6 +134,7 @@
Date range filter
Target moves filter
Account at 0 filter
+
Inactive accounts filter
Limit hierarchy levels
@@ -151,6 +152,10 @@ Hide Show
+
+ Show + Hide +
Level diff --git a/account_financial_report/report/trial_balance.py b/account_financial_report/report/trial_balance.py index da37df5c0..9a1b241d7 100644 --- a/account_financial_report/report/trial_balance.py +++ b/account_financial_report/report/trial_balance.py @@ -347,10 +347,13 @@ def _get_data( only_posted_moves, show_partner_details, hide_account_at_0, + include_inactive_accounts, unaffected_earnings_account, fy_start_date, ): accounts_domain = [("company_id", "=", company_id)] + if not include_inactive_accounts: + accounts_domain += [("deprecated", "=", False)] if account_ids: accounts_domain += [("id", "in", account_ids)] # If explicit list of accounts is provided, @@ -670,6 +673,7 @@ def _get_report_values(self, docids, data): date_to = data["date_to"] date_from = data["date_from"] hide_account_at_0 = data["hide_account_at_0"] + include_inactive_accounts = data["include_inactive_accounts"] show_hierarchy = data["show_hierarchy"] show_hierarchy_level = data["show_hierarchy_level"] foreign_currency = data["foreign_currency"] @@ -687,6 +691,7 @@ def _get_report_values(self, docids, data): only_posted_moves, show_partner_details, hide_account_at_0, + include_inactive_accounts, unaffected_earnings_account, fy_start_date, ) @@ -748,6 +753,7 @@ def _get_report_values(self, docids, data): "date_to": data["date_to"], "only_posted_moves": data["only_posted_moves"], "hide_account_at_0": data["hide_account_at_0"], + "include_inactive_accounts": data["include_inactive_accounts"], "show_partner_details": data["show_partner_details"], "limit_hierarchy_level": data["limit_hierarchy_level"], "show_hierarchy": show_hierarchy, diff --git a/account_financial_report/report/trial_balance_xlsx.py b/account_financial_report/report/trial_balance_xlsx.py index 68a871c06..ca0ba0117 100644 --- a/account_financial_report/report/trial_balance_xlsx.py +++ b/account_financial_report/report/trial_balance_xlsx.py @@ -143,6 +143,10 @@ def _get_report_filters(self, report): _("Account at 0 filter"), _("Hide") if report.hide_account_at_0 else _("Show"), ], + [ + _("Inactive accounts filter"), + _("Show") if report.include_inactive_accounts else _("Hide"), + ], [ _("Show foreign currency"), _("Yes") if report.foreign_currency else _("No"), diff --git a/account_financial_report/wizard/trial_balance_wizard.py b/account_financial_report/wizard/trial_balance_wizard.py index 9c47c96d7..8bbc3c245 100644 --- a/account_financial_report/wizard/trial_balance_wizard.py +++ b/account_financial_report/wizard/trial_balance_wizard.py @@ -45,6 +45,9 @@ class TrialBalanceReportWizard(models.TransientModel): "not display accounts that have initial balance = " "debit = credit = end balance = 0", ) + include_inactive_accounts = fields.Boolean( + help="Use this filter to include deprecated(inactive accounts)", + ) receivable_accounts_only = fields.Boolean() payable_accounts_only = fields.Boolean() show_partner_details = fields.Boolean() @@ -68,7 +71,7 @@ class TrialBalanceReportWizard(models.TransientModel): help="Ending account in a range", ) - @api.onchange("account_code_from", "account_code_to") + @api.onchange("account_code_from", "account_code_to", "include_inactive_accounts") def on_change_account_range(self): if ( self.account_code_from @@ -78,9 +81,10 @@ def on_change_account_range(self): ): start_range = int(self.account_code_from.code) end_range = int(self.account_code_to.code) - self.account_ids = self.env["account.account"].search( - [("code", ">=", start_range), ("code", "<=", end_range)] - ) + accounts_domain = [("code", ">=", start_range), ("code", "<=", end_range)] + if not self.include_inactive_accounts: + accounts_domain += [("deprecated", "=", False)] + self.account_ids = self.env["account.account"].search(accounts_domain) if self.company_id: self.account_ids = self.account_ids.filtered( lambda a: a.company_id == self.company_id @@ -107,7 +111,7 @@ def _compute_fy_start_date(self): else: wiz.fy_start_date = False - @api.onchange("company_id") + @api.onchange("company_id", "include_inactive_accounts") def onchange_company_id(self): """Handle company change.""" count = self.env["account.account"].search_count( @@ -149,7 +153,10 @@ def onchange_company_id(self): if not self.company_id: return res else: - res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)] + accounts_domain = [("company_id", "=", self.company_id.id)] + if not self.include_inactive_accounts: + accounts_domain += [("deprecated", "=", False)] + res["domain"]["account_ids"] += accounts_domain res["domain"]["partner_ids"] += self._get_partner_ids_domain() res["domain"]["date_range_id"] += [ "|", @@ -180,11 +187,15 @@ def _check_company_id_date_range_id(self): ) ) - @api.onchange("receivable_accounts_only", "payable_accounts_only") + @api.onchange( + "receivable_accounts_only", "payable_accounts_only", "include_inactive_accounts" + ) def onchange_type_accounts_only(self): """Handle receivable/payable accounts only change.""" if self.receivable_accounts_only or self.payable_accounts_only: domain = [("company_id", "=", self.company_id.id)] + if not self.include_inactive_accounts: + domain += [("deprecated", "=", False)] if self.receivable_accounts_only and self.payable_accounts_only: domain += [ ("account_type", "in", ("asset_receivable", "liability_payable")) @@ -245,6 +256,7 @@ def _prepare_report_trial_balance(self): "date_to": self.date_to, "only_posted_moves": self.target_move == "posted", "hide_account_at_0": self.hide_account_at_0, + "include_inactive_accounts": self.include_inactive_accounts, "foreign_currency": self.foreign_currency, "company_id": self.company_id.id, "account_ids": self.account_ids.ids or [], diff --git a/account_financial_report/wizard/trial_balance_wizard_view.xml b/account_financial_report/wizard/trial_balance_wizard_view.xml index 11fc754bd..0b76c5591 100644 --- a/account_financial_report/wizard/trial_balance_wizard_view.xml +++ b/account_financial_report/wizard/trial_balance_wizard_view.xml @@ -26,6 +26,7 @@ +