Browse Source

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()
pull/469/head
Alexis de Lattre 6 years ago
committed by Jordi Ballester Alomar
parent
commit
faa829e789
  1. 21
      account_financial_report_qweb/wizard/aged_partner_balance_wizard.py
  2. 2
      account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml
  3. 21
      account_financial_report_qweb/wizard/general_ledger_wizard.py
  4. 2
      account_financial_report_qweb/wizard/general_ledger_wizard_view.xml
  5. 21
      account_financial_report_qweb/wizard/open_items_wizard.py
  6. 2
      account_financial_report_qweb/wizard/open_items_wizard_view.xml
  7. 21
      account_financial_report_qweb/wizard/trial_balance_wizard.py
  8. 2
      account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

21
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()

2
account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml

@ -27,7 +27,7 @@
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
</group>
<field name="account_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>

21
account_financial_report_qweb/wizard/general_ledger_wizard.py

@ -110,6 +110,27 @@ class GeneralLedgerReportWizard(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(GeneralLedgerReportWizard, self).create(vals)
return res
@api.onchange('partner_ids')
def onchange_partner_ids(self):
"""Handle partners change."""

2
account_financial_report_qweb/wizard/general_ledger_wizard_view.xml

@ -39,7 +39,7 @@
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
</group>
<field name="account_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
</div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>

21
account_financial_report_qweb/wizard/open_items_wizard.py

@ -67,6 +67,27 @@ class OpenItemsReportWizard(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(OpenItemsReportWizard, self).create(vals)
return res
@api.multi
def button_export_html(self):
self.ensure_one()

2
account_financial_report_qweb/wizard/open_items_wizard_view.xml

@ -28,7 +28,7 @@
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
</group>
<field name="account_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>

21
account_financial_report_qweb/wizard/trial_balance_wizard.py

@ -105,6 +105,27 @@ class TrialBalanceReportWizard(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(TrialBalanceReportWizard, self).create(vals)
return res
@api.onchange('show_partner_details')
def onchange_show_partner_details(self):
"""Handle partners change."""

2
account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

@ -35,7 +35,7 @@
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
</group>
<field name="account_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
</div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>

Loading…
Cancel
Save