2
0

[FIX] account_chart_update: Handle updated m2m correctly

This commit is contained in:
Pedro M. Baeza 2018-09-21 23:24:53 +02:00 committed by Luis J. Salvatierra
parent 768276e964
commit e206a37bdd
4 changed files with 31 additions and 18 deletions

View File

@ -8,7 +8,7 @@
{ {
'name': "Detect changes and update the Account Chart from a template", 'name': "Detect changes and update the Account Chart from a template",
"summary": "Wizard to update a company's account chart from a template", "summary": "Wizard to update a company's account chart from a template",
'version': "11.0.1.0.0", 'version': "11.0.1.0.1",
'author': "Tecnativa, " 'author': "Tecnativa, "
"BCIM, " "BCIM, "
"Okia, " "Okia, "

View File

@ -85,7 +85,7 @@ msgid "Create/Update"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:614 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:616
#, python-format #, python-format
msgid "Created account %s." msgid "Created account %s."
msgstr "" msgstr ""
@ -107,19 +107,19 @@ msgid "Created on"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:715 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:717
#, python-format #, python-format
msgid "Created or updated fiscal position %s." msgid "Created or updated fiscal position %s."
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:581 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:583
#, python-format #, python-format
msgid "Created tax %s." msgid "Created tax %s."
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:576 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:578
#, python-format #, python-format
msgid "Deactivated tax %s." msgid "Deactivated tax %s."
msgstr "" msgstr ""
@ -135,7 +135,7 @@ msgid "Determines where the tax is selectable. Note : 'None' means a tax can't b
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:451 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:453
#, python-format #, python-format
msgid "Differences in these fields: %s." msgid "Differences in these fields: %s."
msgstr "" msgstr ""
@ -149,13 +149,13 @@ msgid "Display Name"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:623 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:625
#, python-format #, python-format
msgid "Exception creating account %s." msgid "Exception creating account %s."
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:645 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:647
#, python-format #, python-format
msgid "Exception writing account %s." msgid "Exception writing account %s."
msgstr "" msgstr ""
@ -264,7 +264,7 @@ msgid "Messages and Errors"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:475 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:477
#, python-format #, python-format
msgid "Name or description not found." msgid "Name or description not found."
msgstr "" msgstr ""
@ -297,13 +297,13 @@ msgid "Next"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:518 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:520
#, python-format #, python-format
msgid "No account found with this code." msgid "No account found with this code."
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:552 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:554
#, python-format #, python-format
msgid "No fiscal position found with this name." msgid "No fiscal position found with this name."
msgstr "" msgstr ""
@ -339,7 +339,7 @@ msgid "Other options"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:668 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:670
#, python-format #, python-format
msgid "Post-updated tax %s." msgid "Post-updated tax %s."
msgstr "" msgstr ""
@ -390,7 +390,7 @@ msgid "Tax Scope"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:456 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:458
#, python-format #, python-format
msgid "Tax is disabled." msgid "Tax is disabled."
msgstr "" msgstr ""
@ -427,7 +427,7 @@ msgid "This wizard will update your accounts, taxes and fiscal positions accordi
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:502 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:504
#, python-format #, python-format
msgid "To deactivate: not in the template" msgid "To deactivate: not in the template"
msgstr "" msgstr ""
@ -487,7 +487,7 @@ msgid "Update taxes"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:636 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:638
#, python-format #, python-format
msgid "Updated account %s." msgid "Updated account %s."
msgstr "" msgstr ""
@ -503,7 +503,7 @@ msgid "Updated fiscal positions"
msgstr "" msgstr ""
#. module: account_chart_update #. module: account_chart_update
#: code:addons/account_chart_update/wizard/wizard_chart_update.py:589 #: code:addons/account_chart_update/wizard/wizard_chart_update.py:591
#, python-format #, python-format
msgid "Updated tax %s." msgid "Updated tax %s."
msgstr "" msgstr ""

View File

@ -90,6 +90,12 @@ class TestAccountChartUpdate(common.HttpCase):
self.tax_group = self.env['account.tax.group'].create({ self.tax_group = self.env['account.tax.group'].create({
'name': 'Test tax group', 'name': 'Test tax group',
}) })
self.account_tag_1 = self.env['account.account.tag'].create({
'name': 'Test account tag 1',
})
self.account_tag_2 = self.env['account.account.tag'].create({
'name': 'Test account tag 2',
})
self.company = self.env['res.company'].create({ self.company = self.env['res.company'].create({
'name': 'Test account_chart_update company', 'name': 'Test account_chart_update company',
'currency_id': self.chart_template.currency_id.id, 'currency_id': self.chart_template.currency_id.id,
@ -214,6 +220,9 @@ class TestAccountChartUpdate(common.HttpCase):
self.tax_template.tax_group_id = self.tax_group.id self.tax_template.tax_group_id = self.tax_group.id
self.tax_template.refund_account_id = new_account_tmpl.id self.tax_template.refund_account_id = new_account_tmpl.id
self.account_template.name = "Other name" self.account_template.name = "Other name"
self.account_template.tag_ids = [
(6, 0, [self.account_tag_1.id, self.account_tag_2.id]),
]
self.fp_template.note = "Test note" self.fp_template.note = "Test note"
self.fp_template.account_ids.account_dest_id = new_account_tmpl.id self.fp_template.account_ids.account_dest_id = new_account_tmpl.id
self.fp_template.tax_ids.tax_dest_id = self.tax_template.id self.fp_template.tax_ids.tax_dest_id = self.tax_template.id
@ -239,6 +248,8 @@ class TestAccountChartUpdate(common.HttpCase):
self.assertEqual(self.tax.tax_group_id, self.tax_group) self.assertEqual(self.tax.tax_group_id, self.tax_group)
self.assertEqual(self.tax.refund_account_id, new_account) self.assertEqual(self.tax.refund_account_id, new_account)
self.assertEqual(self.account.name, self.account_template.name) self.assertEqual(self.account.name, self.account_template.name)
self.assertIn(self.account_tag_1, self.account.tag_ids)
self.assertIn(self.account_tag_2, self.account.tag_ids)
self.assertEqual(self.fp.note, self.fp_template.note) self.assertEqual(self.fp.note, self.fp_template.note)
self.assertEqual(self.fp.account_ids.account_dest_id, new_account) self.assertEqual(self.fp.account_ids.account_dest_id, new_account)
self.assertEqual(self.fp.tax_ids.tax_dest_id, self.tax) self.assertEqual(self.fp.tax_ids.tax_dest_id, self.tax)

View File

@ -422,8 +422,10 @@ class WizardUpdateChartsAccounts(models.TransientModel):
result[key] = expected result[key] = expected
elif template[key] != real[key]: elif template[key] != real[key]:
result[key] = template[key] result[key] = template[key]
if isinstance(result.get(key, False), models.Model):
# Avoid to cache recordset references # Avoid to cache recordset references
if isinstance(real._fields[key], fields.Many2many):
result[key] = [(6, 0, result[key].ids)]
elif isinstance(real._fields[key], fields.Many2one):
result[key] = result[key].id result[key] = result[key].id
except KeyError: except KeyError:
pass pass