diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py index 0596c6ca67cc..70d978449664 100644 --- a/account_financial_report/wizard/general_ledger_wizard.py +++ b/account_financial_report/wizard/general_ledger_wizard.py @@ -104,17 +104,18 @@ def _get_account_move_lines_domain(self): @api.onchange("account_code_from", "account_code_to") def on_change_account_range(self): - if ( - self.account_code_from - and self.account_code_from.code.isdigit() - 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) - self.account_ids = self.env["account.account"].search( - [("code", ">=", start_range), ("code", "<=", end_range)] - ) + if self.account_code_from and self.account_code_to: + start_range = self.account_code_from.code + end_range = self.account_code_to.code + + accounts = self.env["account.account"].search([]) + account_codes = [account.code for account in accounts] + + start_index = account_codes.index(start_range) + end_index = account_codes.index(end_range) + + self.account_ids = accounts[start_index : end_index + 1] + if self.company_id: self.account_ids = self.account_ids.filtered( lambda a: a.company_id == self.company_id