From faa829e789a480d9b381dc957bdc3de10d4fc41d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 5 Sep 2018 11:20:23 +0200 Subject: [PATCH] Improve workaround for bug https://github.com/odoo/odoo/issues/14761 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). We now use the regular M2M widget and inherit create() --- .../wizard/aged_partner_balance_wizard.py | 21 +++++++++++++++++++ .../aged_partner_balance_wizard_view.xml | 2 +- .../wizard/general_ledger_wizard.py | 21 +++++++++++++++++++ .../wizard/general_ledger_wizard_view.xml | 2 +- .../wizard/open_items_wizard.py | 21 +++++++++++++++++++ .../wizard/open_items_wizard_view.xml | 2 +- .../wizard/trial_balance_wizard.py | 21 +++++++++++++++++++ .../wizard/trial_balance_wizard_view.xml | 2 +- 8 files changed, 88 insertions(+), 4 deletions(-) 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 @@ - +