diff --git a/account_financial_report/wizard/aged_partner_balance_wizard.py b/account_financial_report/wizard/aged_partner_balance_wizard.py index ac624f63..45206a68 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report/wizard/aged_partner_balance_wizard.py @@ -40,6 +40,34 @@ class AgedPartnerBalanceWizard(models.TransientModel): ) show_move_line_details = fields.Boolean() + account_code_from = fields.Many2one( + comodel_name='account.account', + string='Account Code From', + help='Starting account in a range') + account_code_to = fields.Many2one( + comodel_name='account.account', + string='Account Code To', + help='Ending account in a range') + + @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', 'in', [ + x for x in range(start_range, end_range + 1)]), + ('reconcile', '=', True) + ]) + if self.company_id: + self.account_ids = self.account_ids.filtered( + lambda a: a.company_id == self.company_id) + return {'domain': { + 'account_code_from': [('reconcile', '=', True)], + 'account_code_to': [('reconcile', '=', True)] + }} + @api.onchange('company_id') def onchange_company_id(self): """Handle company change.""" diff --git a/account_financial_report/wizard/aged_partner_balance_wizard_view.xml b/account_financial_report/wizard/aged_partner_balance_wizard_view.xml index 7b7e8d93..684d19e1 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard_view.xml +++ b/account_financial_report/wizard/aged_partner_balance_wizard_view.xml @@ -29,6 +29,21 @@