Skip to content

Commit

Permalink
Merge PR #1112 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 22, 2024
2 parents 8c5d793 + 14c8da1 commit 58ed5f0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions account_financial_report/tests/test_trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def setUpClass(cls, chart_template_ref=None):
)
cls.group2 = group_obj.create({"code_prefix_start": "2", "name": "Group 2"})
# Set accounts
cls.account001 = cls._create_account_account(
cls,
{
"code": "001",
"name": "Account 001",
"group_id": cls.group2.id,
"account_type": "income_other",
},
)
cls.account100 = cls.company_data["default_account_receivable"]
cls.account100.group_id = cls.group1.id
cls.account110 = cls.env["account.account"].search(
Expand Down Expand Up @@ -675,3 +684,33 @@ def test_04_undistributed_pl(self):
self.assertEqual(total_initial_balance, 0)
self.assertEqual(total_final_balance, 0)
self.assertEqual(total_debit, total_credit)

def test_05_all_accounts_loaded(self):
# Tests if all accounts are loaded when the account_code_ fields changed
all_accounts = self.env["account.account"].search([], order="code")
company = self.env.user.company_id
trial_balance = self.env["trial.balance.report.wizard"].create(
{
"date_from": self.date_start,
"date_to": self.date_end,
"target_move": "posted",
"hide_account_at_0": False,
"show_hierarchy": False,
"company_id": company.id,
"fy_start_date": self.fy_date_start,
"account_code_from": self.account001.id,
"account_code_to": all_accounts[-1].id,
}
)
trial_balance.on_change_account_range()
# sets are needed because some codes are duplicated and
# thus the length of all_accounts would be higher
all_accounts_code_set = set()
trial_balance_code_set = set()
[all_accounts_code_set.add(account.code) for account in all_accounts]
[
trial_balance_code_set.add(account.code)
for account in trial_balance.account_ids
]
self.assertEqual(len(trial_balance_code_set), len(all_accounts_code_set))
self.assertTrue(trial_balance_code_set == all_accounts_code_set)
4 changes: 2 additions & 2 deletions account_financial_report/wizard/trial_balance_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def on_change_account_range(self):
and self.account_code_to
and self.account_code_to.code.isdigit()
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
start_range = self.account_code_from.code
end_range = self.account_code_to.code
self.account_ids = self.env["account.account"].search(
[("code", ">=", start_range), ("code", "<=", end_range)]
)
Expand Down

0 comments on commit 58ed5f0

Please sign in to comment.