From afe0090e8d1665a4b2d8bf01be14c965b0827044 Mon Sep 17 00:00:00 2001 From: Joan Sisquella Date: Thu, 30 Apr 2020 15:35:09 +0200 Subject: [PATCH] [IMP] account_financial_report: select accounts between two codes --- .../wizard/aged_partner_balance_wizard.py | 28 +++++++++++++++++ .../aged_partner_balance_wizard_view.xml | 15 +++++++++ .../wizard/general_ledger_wizard.py | 25 ++++++++++++--- .../wizard/general_ledger_wizard_view.xml | 31 ++++++++++++++----- .../wizard/open_items_wizard.py | 27 ++++++++++++++++ .../wizard/open_items_wizard_view.xml | 16 ++++++++++ .../wizard/trial_balance_wizard.py | 21 +++++++++++++ .../wizard/trial_balance_wizard_view.xml | 16 ++++++++-- 8 files changed, 166 insertions(+), 13 deletions(-) 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 @@