diff --git a/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py b/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py index 6e7e135e..934e66f1 100644 --- a/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report_qweb/wizard/aged_partner_balance_wizard.py @@ -54,6 +54,27 @@ class AgedPartnerBalance(models.TransientModel): else: self.account_ids = None + @api.model + def create(self, vals): + """ + This is a workaround for bug https://github.com/odoo/odoo/issues/14761 + This bug impacts M2M fields in wizards filled-up via onchange + It replaces the workaround widget="many2many_tags" on + field name="account_ids" which prevented from selecting several + accounts at the same time (quite useful when you want to select + an interval of accounts for example) + """ + if 'account_ids' in vals and isinstance(vals['account_ids'], list): + account_ids = [] + for account in vals['account_ids']: + if account[0] in (1, 4): + account_ids.append(account[1]) + elif account[0] == 6 and isinstance(account[2], list): + account_ids += account[2] + vals['account_ids'] = [(6, 0, account_ids)] + res = super(AgedPartnerBalance, self).create(vals) + return res + @api.multi def button_export_html(self): self.ensure_one() diff --git a/account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml b/account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml index 03be0cfb..b2584dcd 100644 --- a/account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml +++ b/account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml @@ -27,7 +27,7 @@ - +