mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_chart_update: Additional needed changes
This commit is contained in:
committed by
Reyes4711
parent
f9642d9e84
commit
0f19f777a9
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from odoo import fields
|
from odoo import fields
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
|
from odoo.tools import mute_logger
|
||||||
|
|
||||||
|
|
||||||
class TestAccountChartUpdate(common.HttpCase):
|
class TestAccountChartUpdate(common.HttpCase):
|
||||||
@@ -126,6 +127,7 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
'lang': 'en_US'
|
'lang': 'en_US'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mute_logger('odoo.sql_db')
|
||||||
def test_chart_update(self):
|
def test_chart_update(self):
|
||||||
# Test no changes
|
# Test no changes
|
||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from io import StringIO
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
EXCEPTION_TEXT = u"Traceback (most recent call last)"
|
EXCEPTION_TEXT = "Traceback (most recent call last)"
|
||||||
|
|
||||||
|
|
||||||
class WizardUpdateChartsAccounts(models.TransientModel):
|
class WizardUpdateChartsAccounts(models.TransientModel):
|
||||||
@@ -286,7 +286,8 @@ class WizardUpdateChartsAccounts(models.TransientModel):
|
|||||||
def find_account_by_templates(self, templates):
|
def find_account_by_templates(self, templates):
|
||||||
"""Find an account that matches the template."""
|
"""Find an account that matches the template."""
|
||||||
return self.env['account.account'].search(
|
return self.env['account.account'].search(
|
||||||
[('code', 'in', map(self.padded_code, templates.mapped("code"))),
|
[('code', 'in',
|
||||||
|
list(map(self.padded_code, templates.mapped("code")))),
|
||||||
('company_id', '=', self.company_id.id)],
|
('company_id', '=', self.company_id.id)],
|
||||||
).id
|
).id
|
||||||
|
|
||||||
@@ -387,7 +388,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
|
|||||||
"""
|
"""
|
||||||
result = dict()
|
result = dict()
|
||||||
ignore = self.fields_to_ignore(template, template._name)
|
ignore = self.fields_to_ignore(template, template._name)
|
||||||
for key, field in template._fields.iteritems():
|
for key, field in template._fields.items():
|
||||||
if key in ignore:
|
if key in ignore:
|
||||||
continue
|
continue
|
||||||
expected = t = None
|
expected = t = None
|
||||||
@@ -444,7 +445,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
|
|||||||
result = list()
|
result = list()
|
||||||
different_fields = sorted(
|
different_fields = sorted(
|
||||||
template._fields[f].get_description(self.env)["string"]
|
template._fields[f].get_description(self.env)["string"]
|
||||||
for f in list(self.diff_fields(template, real).keys()))
|
for f in self.diff_fields(template, real).keys())
|
||||||
if different_fields:
|
if different_fields:
|
||||||
result.append(
|
result.append(
|
||||||
_("Differences in these fields: %s.") %
|
_("Differences in these fields: %s.") %
|
||||||
@@ -580,7 +581,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
|
|||||||
_logger.info(_("Created tax %s."), "'%s'" % template.name)
|
_logger.info(_("Created tax %s."), "'%s'" % template.name)
|
||||||
# Update tax
|
# Update tax
|
||||||
else:
|
else:
|
||||||
for key, value in self.diff_fields(template, tax).iteritems():
|
for key, value in self.diff_fields(template, tax).items():
|
||||||
# We defer update because account might not be created yet
|
# We defer update because account might not be created yet
|
||||||
if key in {'account_id', 'refund_account_id'}:
|
if key in {'account_id', 'refund_account_id'}:
|
||||||
continue
|
continue
|
||||||
@@ -659,7 +660,7 @@ class WizardUpdateChartsAccounts(models.TransientModel):
|
|||||||
template = wiz_tax.tax_id
|
template = wiz_tax.tax_id
|
||||||
tax = wiz_tax.update_tax_id
|
tax = wiz_tax.update_tax_id
|
||||||
done = False
|
done = False
|
||||||
for key, value in self.diff_fields(template, tax).iteritems():
|
for key, value in self.diff_fields(template, tax).items():
|
||||||
if key in {'account_id', 'refund_account_id'}:
|
if key in {'account_id', 'refund_account_id'}:
|
||||||
tax[key] = value
|
tax[key] = value
|
||||||
done = True
|
done = True
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<field name="company_id"
|
<field name="company_id"
|
||||||
attrs="{'invisible':[('state','!=','init')]}"
|
attrs="{'invisible':[('state','!=','init')]}"
|
||||||
/>
|
/>
|
||||||
<field name="code_digits" attrs="{'invisible':[('state','!=','init')]}" />
|
<field name="code_digits" invisible="1" />
|
||||||
<field name="chart_template_id"
|
<field name="chart_template_id"
|
||||||
domain="[('visible', '=', True)]"
|
domain="[('visible', '=', True)]"
|
||||||
attrs="{'invisible': [('state','!=','init')], 'required': True}"
|
attrs="{'invisible': [('state','!=','init')], 'required': True}"
|
||||||
|
|||||||
Reference in New Issue
Block a user