Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions account_financial_report/report/templates/trial_balance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<div class="act_as_cell">Date range filter</div>
<div class="act_as_cell">Target moves filter</div>
<div class="act_as_cell">Account at 0 filter</div>
<div class="act_as_cell">Inactive accounts filter</div>
<div class="act_as_cell">Limit hierarchy levels</div>
</div>
<div class="act_as_row">
Expand All @@ -151,6 +152,10 @@
<t t-if="hide_account_at_0">Hide</t>
<t t-if="not hide_account_at_0">Show</t>
</div>
<div class="act_as_cell">
<t t-if="include_inactive_accounts">Show</t>
<t t-if="not include_inactive_accounts">Hide</t>
</div>
<div class="act_as_cell">
<t t-if="limit_hierarchy_level">
Level
Expand Down
6 changes: 6 additions & 0 deletions account_financial_report/report/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"]
Expand All @@ -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,
)
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions account_financial_report/report/trial_balance_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
26 changes: 19 additions & 7 deletions account_financial_report/wizard/trial_balance_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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"] += [
"|",
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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 [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<group name="other_filters">
<field name="target_move" widget="radio" />
<field name="hide_account_at_0" />
<field name="include_inactive_accounts" />
<field name="show_partner_details" />
<field
name="show_hierarchy"
Expand Down