[IMP] account_chart_update: black, isort
This commit is contained in:
parent
14ff14c635
commit
2e7396b485
@ -8,10 +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": "12.0.1.0.0",
|
"version": "12.0.1.0.0",
|
||||||
"author": "Tecnativa, "
|
"author": "Tecnativa, " "BCIM, " "Okia, " "Odoo Community Association (OCA)",
|
||||||
"BCIM, "
|
|
||||||
"Okia, "
|
|
||||||
"Odoo Community Association (OCA)",
|
|
||||||
"website": "http://github.com/OCA/account-financial-tools",
|
"website": "http://github.com/OCA/account-financial-tools",
|
||||||
"depends": ["account"],
|
"depends": ["account"],
|
||||||
"category": "Accounting",
|
"category": "Accounting",
|
||||||
|
@ -5,15 +5,15 @@ from odoo import models
|
|||||||
|
|
||||||
|
|
||||||
class IrModelFields(models.Model):
|
class IrModelFields(models.Model):
|
||||||
_inherit = 'ir.model.fields'
|
_inherit = "ir.model.fields"
|
||||||
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
"""Return special label when showing fields in chart update wizard."""
|
"""Return special label when showing fields in chart update wizard."""
|
||||||
if self.env.context.get('account_chart_update'):
|
if self.env.context.get("account_chart_update"):
|
||||||
res = []
|
res = []
|
||||||
for record in self:
|
for record in self:
|
||||||
res.append((record.id, "%s (%s)" % (
|
res.append(
|
||||||
record.field_description, record.name,
|
(record.id, "{} ({})".format(record.field_description, record.name))
|
||||||
)))
|
)
|
||||||
return res
|
return res
|
||||||
return super(IrModelFields, self).name_get()
|
return super(IrModelFields, self).name_get()
|
||||||
|
@ -10,130 +10,139 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
post_install = True
|
post_install = True
|
||||||
|
|
||||||
def _create_xml_id(self, record):
|
def _create_xml_id(self, record):
|
||||||
return self.env['ir.model.data'].create({
|
return self.env["ir.model.data"].create(
|
||||||
'module': 'account_chart_update',
|
{
|
||||||
'name': "%s-%s" % (record._table, record.id),
|
"module": "account_chart_update",
|
||||||
'model': record._name,
|
"name": "{}-{}".format(record._table, record.id),
|
||||||
'res_id': record.id,
|
"model": record._name,
|
||||||
})
|
"res_id": record.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _create_account_tmpl(self, name, code, user_type, chart_template):
|
def _create_account_tmpl(self, name, code, user_type, chart_template):
|
||||||
record = self.env['account.account.template'].create({
|
record = self.env["account.account.template"].create(
|
||||||
'name': name,
|
{
|
||||||
'code': code,
|
"name": name,
|
||||||
'user_type_id': user_type.id,
|
"code": code,
|
||||||
'chart_template_id': chart_template and chart_template.id,
|
"user_type_id": user_type.id,
|
||||||
})
|
"chart_template_id": chart_template and chart_template.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
self._create_xml_id(record)
|
self._create_xml_id(record)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
def _create_tax_tmpl(self, name, chart_template):
|
def _create_tax_tmpl(self, name, chart_template):
|
||||||
record = self.env['account.tax.template'].create({
|
record = self.env["account.tax.template"].create(
|
||||||
'name': name,
|
{
|
||||||
'amount': 0,
|
"name": name,
|
||||||
'chart_template_id': chart_template.id,
|
"amount": 0,
|
||||||
'tax_group_id': self.env.ref('account.tax_group_taxes').id,
|
"chart_template_id": chart_template.id,
|
||||||
})
|
"tax_group_id": self.env.ref("account.tax_group_taxes").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
self._create_xml_id(record)
|
self._create_xml_id(record)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
def _create_fp_tmpl(self, name, chart_template):
|
def _create_fp_tmpl(self, name, chart_template):
|
||||||
record = self.env['account.fiscal.position.template'].create({
|
record = self.env["account.fiscal.position.template"].create(
|
||||||
'name': name,
|
{"name": name, "chart_template_id": chart_template.id}
|
||||||
'chart_template_id': chart_template.id,
|
)
|
||||||
})
|
|
||||||
self._create_xml_id(record)
|
self._create_xml_id(record)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
def _get_model_data(self, record):
|
def _get_model_data(self, record):
|
||||||
return self.env['ir.model.data'].search([
|
return self.env["ir.model.data"].search(
|
||||||
('model', '=', record._name),
|
[("model", "=", record._name), ("res_id", "=", record.id)]
|
||||||
('res_id', '=', record.id),
|
)
|
||||||
])
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestAccountChartUpdate, self).setUp()
|
super(TestAccountChartUpdate, self).setUp()
|
||||||
# Make sure user is in English
|
# Make sure user is in English
|
||||||
self.env.user.lang = 'en_US'
|
self.env.user.lang = "en_US"
|
||||||
self.account_type = self.env['account.account.type'].create({
|
self.account_type = self.env["account.account.type"].create(
|
||||||
'name': 'Test account_chart_update account type',
|
{"name": "Test account_chart_update account type"}
|
||||||
})
|
)
|
||||||
self.account_template = self._create_account_tmpl(
|
self.account_template = self._create_account_tmpl(
|
||||||
'Test', '100000', self.account_type, False,
|
"Test", "100000", self.account_type, False
|
||||||
|
)
|
||||||
|
self.chart_template = self.env["account.chart.template"].create(
|
||||||
|
{
|
||||||
|
"name": "Test account_chart_update chart",
|
||||||
|
"currency_id": self.env.ref("base.EUR").id,
|
||||||
|
"code_digits": 6,
|
||||||
|
"transfer_account_id": self.account_template.id,
|
||||||
|
"cash_account_code_prefix": "570",
|
||||||
|
"bank_account_code_prefix": "572",
|
||||||
|
"transfer_account_code_prefix": "100000",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
self.chart_template = self.env['account.chart.template'].create({
|
|
||||||
'name': 'Test account_chart_update chart',
|
|
||||||
'currency_id': self.env.ref('base.EUR').id,
|
|
||||||
'code_digits': 6,
|
|
||||||
'transfer_account_id': self.account_template.id,
|
|
||||||
'cash_account_code_prefix': '570',
|
|
||||||
'bank_account_code_prefix': '572',
|
|
||||||
'transfer_account_code_prefix': '100000',
|
|
||||||
})
|
|
||||||
self.account_template.chart_template_id = self.chart_template.id
|
self.account_template.chart_template_id = self.chart_template.id
|
||||||
self.account_template_pl = self._create_account_tmpl(
|
self.account_template_pl = self._create_account_tmpl(
|
||||||
'Undistributed Profits/Losses', '999999',
|
"Undistributed Profits/Losses",
|
||||||
|
"999999",
|
||||||
self.env.ref("account.data_unaffected_earnings"),
|
self.env.ref("account.data_unaffected_earnings"),
|
||||||
self.chart_template,
|
self.chart_template,
|
||||||
)
|
)
|
||||||
self.tax_template = self._create_tax_tmpl(
|
self.tax_template = self._create_tax_tmpl("Test tax", self.chart_template)
|
||||||
'Test tax', self.chart_template,
|
self.fp_template = self._create_fp_tmpl("Test fp", self.chart_template)
|
||||||
|
self.fp_template_tax = self.env["account.fiscal.position.tax.template"].create(
|
||||||
|
{"tax_src_id": self.tax_template.id, "position_id": self.fp_template.id}
|
||||||
)
|
)
|
||||||
self.fp_template = self._create_fp_tmpl('Test fp', self.chart_template)
|
|
||||||
self.fp_template_tax = self.env[
|
|
||||||
'account.fiscal.position.tax.template'
|
|
||||||
].create({
|
|
||||||
'tax_src_id': self.tax_template.id,
|
|
||||||
'position_id': self.fp_template.id,
|
|
||||||
})
|
|
||||||
self._create_xml_id(self.fp_template_tax)
|
self._create_xml_id(self.fp_template_tax)
|
||||||
self.fp_template_account = self.env[
|
self.fp_template_account = self.env[
|
||||||
'account.fiscal.position.account.template'
|
"account.fiscal.position.account.template"
|
||||||
].create({
|
].create(
|
||||||
'account_src_id': self.account_template.id,
|
{
|
||||||
'account_dest_id': self.account_template.id,
|
"account_src_id": self.account_template.id,
|
||||||
'position_id': self.fp_template.id,
|
"account_dest_id": self.account_template.id,
|
||||||
})
|
"position_id": self.fp_template.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
self._create_xml_id(self.fp_template_account)
|
self._create_xml_id(self.fp_template_account)
|
||||||
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({
|
self.account_tag_1 = self.env["account.account.tag"].create(
|
||||||
'name': 'Test account tag 1',
|
{"name": "Test account tag 1"}
|
||||||
})
|
)
|
||||||
self.account_tag_2 = self.env['account.account.tag'].create({
|
self.account_tag_2 = self.env["account.account.tag"].create(
|
||||||
'name': 'Test account tag 2',
|
{"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',
|
{
|
||||||
'currency_id': self.chart_template.currency_id.id,
|
"name": "Test account_chart_update company",
|
||||||
})
|
"currency_id": self.chart_template.currency_id.id,
|
||||||
company_user = self.env.user.copy({'company_id': self.company.id})
|
}
|
||||||
|
)
|
||||||
|
company_user = self.env.user.copy({"company_id": self.company.id})
|
||||||
chart_by_company_user = self.chart_template.sudo(company_user)
|
chart_by_company_user = self.chart_template.sudo(company_user)
|
||||||
chart_by_company_user.try_loading_for_current_company()
|
chart_by_company_user.try_loading_for_current_company()
|
||||||
|
|
||||||
self.tax = self.env['account.tax'].search([
|
self.tax = self.env["account.tax"].search(
|
||||||
('name', '=', self.tax_template.name),
|
[
|
||||||
('company_id', '=', self.company.id),
|
("name", "=", self.tax_template.name),
|
||||||
])
|
("company_id", "=", self.company.id),
|
||||||
self.account = self.env['account.account'].search([
|
]
|
||||||
('code', '=', self.account_template.code),
|
)
|
||||||
('company_id', '=', self.company.id),
|
self.account = self.env["account.account"].search(
|
||||||
])
|
[
|
||||||
self.fp = self.env['account.fiscal.position'].search([
|
("code", "=", self.account_template.code),
|
||||||
('name', '=', self.fp_template.name),
|
("company_id", "=", self.company.id),
|
||||||
('company_id', '=', self.company.id),
|
]
|
||||||
])
|
)
|
||||||
|
self.fp = self.env["account.fiscal.position"].search(
|
||||||
|
[("name", "=", self.fp_template.name), ("company_id", "=", self.company.id)]
|
||||||
|
)
|
||||||
# Prepare wizard values
|
# Prepare wizard values
|
||||||
self.wizard_obj = self.env['wizard.update.charts.accounts']
|
self.wizard_obj = self.env["wizard.update.charts.accounts"]
|
||||||
self.wizard_vals = {
|
self.wizard_vals = {
|
||||||
'company_id': self.company.id,
|
"company_id": self.company.id,
|
||||||
'chart_template_id': self.chart_template.id,
|
"chart_template_id": self.chart_template.id,
|
||||||
'code_digits': 6,
|
"code_digits": 6,
|
||||||
'lang': 'en_US'
|
"lang": "en_US",
|
||||||
}
|
}
|
||||||
|
|
||||||
@mute_logger('odoo.sql_db')
|
@mute_logger("odoo.sql_db")
|
||||||
def test_chart_update(self):
|
def test_chart_update(self):
|
||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
@ -141,50 +150,45 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
field = wizard.fp_field_ids[:1]
|
field = wizard.fp_field_ids[:1]
|
||||||
name = field.with_context(account_chart_update=True).name_get()[0]
|
name = field.with_context(account_chart_update=True).name_get()[0]
|
||||||
self.assertEqual(name[0], field.id)
|
self.assertEqual(name[0], field.id)
|
||||||
self.assertEqual(
|
self.assertEqual(name[1], "{} ({})".format(field.field_description, field.name))
|
||||||
name[1], "%s (%s)" % (field.field_description, field.name),
|
|
||||||
)
|
|
||||||
name = field.name_get()[0]
|
name = field.name_get()[0]
|
||||||
self.assertEqual(name[0], field.id)
|
self.assertEqual(name[0], field.id)
|
||||||
self.assertEqual(
|
self.assertEqual(name[1], "{} ({})".format(field.field_description, field.model))
|
||||||
name[1], "%s (%s)" % (field.field_description, field.model),
|
|
||||||
)
|
|
||||||
# Test no changes
|
# Test no changes
|
||||||
self.assertEqual(wizard.state, 'ready')
|
self.assertEqual(wizard.state, "ready")
|
||||||
self.assertFalse(wizard.tax_ids)
|
self.assertFalse(wizard.tax_ids)
|
||||||
self.assertFalse(wizard.account_ids)
|
self.assertFalse(wizard.account_ids)
|
||||||
self.assertFalse(wizard.fiscal_position_ids)
|
self.assertFalse(wizard.fiscal_position_ids)
|
||||||
wizard.unlink()
|
wizard.unlink()
|
||||||
# Add templates
|
# Add templates
|
||||||
new_tax_tmpl = self._create_tax_tmpl(
|
new_tax_tmpl = self._create_tax_tmpl("Test tax 2", self.chart_template)
|
||||||
'Test tax 2', self.chart_template,
|
|
||||||
)
|
|
||||||
new_account_tmpl = self._create_account_tmpl(
|
new_account_tmpl = self._create_account_tmpl(
|
||||||
'Test account 2', '333333', self.account_type, self.chart_template,
|
"Test account 2", "333333", self.account_type, self.chart_template
|
||||||
|
)
|
||||||
|
new_fp = self._create_fp_tmpl("Test fp 2", self.chart_template)
|
||||||
|
fp_template_tax = self.env["account.fiscal.position.tax.template"].create(
|
||||||
|
{"tax_src_id": self.tax_template.id, "position_id": new_fp.id}
|
||||||
)
|
)
|
||||||
new_fp = self._create_fp_tmpl('Test fp 2', self.chart_template)
|
|
||||||
fp_template_tax = self.env[
|
|
||||||
'account.fiscal.position.tax.template'
|
|
||||||
].create({
|
|
||||||
'tax_src_id': self.tax_template.id,
|
|
||||||
'position_id': new_fp.id,
|
|
||||||
})
|
|
||||||
self._create_xml_id(fp_template_tax)
|
self._create_xml_id(fp_template_tax)
|
||||||
fp_template_account = self.env[
|
fp_template_account = self.env[
|
||||||
'account.fiscal.position.account.template'
|
"account.fiscal.position.account.template"
|
||||||
].create({
|
].create(
|
||||||
'account_src_id': self.account_template.id,
|
{
|
||||||
'account_dest_id': self.account_template.id,
|
"account_src_id": self.account_template.id,
|
||||||
'position_id': new_fp.id,
|
"account_dest_id": self.account_template.id,
|
||||||
})
|
"position_id": new_fp.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
self._create_xml_id(fp_template_account)
|
self._create_xml_id(fp_template_account)
|
||||||
# Check that no action is performed if the option is not selected
|
# Check that no action is performed if the option is not selected
|
||||||
wizard_vals = self.wizard_vals.copy()
|
wizard_vals = self.wizard_vals.copy()
|
||||||
wizard_vals.update({
|
wizard_vals.update(
|
||||||
'update_tax': False,
|
{
|
||||||
'update_account': False,
|
"update_tax": False,
|
||||||
'update_fiscal_position': False,
|
"update_account": False,
|
||||||
})
|
"update_fiscal_position": False,
|
||||||
|
}
|
||||||
|
)
|
||||||
wizard = self.wizard_obj.create(wizard_vals)
|
wizard = self.wizard_obj.create(wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertFalse(wizard.tax_ids)
|
self.assertFalse(wizard.tax_ids)
|
||||||
@ -196,33 +200,30 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertTrue(wizard.tax_ids)
|
self.assertTrue(wizard.tax_ids)
|
||||||
self.assertEqual(wizard.tax_ids.tax_id, new_tax_tmpl)
|
self.assertEqual(wizard.tax_ids.tax_id, new_tax_tmpl)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'new')
|
self.assertEqual(wizard.tax_ids.type, "new")
|
||||||
self.assertTrue(wizard.account_ids)
|
self.assertTrue(wizard.account_ids)
|
||||||
self.assertEqual(wizard.account_ids.account_id, new_account_tmpl)
|
self.assertEqual(wizard.account_ids.account_id, new_account_tmpl)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'new')
|
self.assertEqual(wizard.tax_ids.type, "new")
|
||||||
self.assertTrue(wizard.fiscal_position_ids)
|
self.assertTrue(wizard.fiscal_position_ids)
|
||||||
self.assertEqual(wizard.fiscal_position_ids.fiscal_position_id, new_fp)
|
self.assertEqual(wizard.fiscal_position_ids.fiscal_position_id, new_fp)
|
||||||
self.assertEqual(wizard.fiscal_position_ids.type, 'new')
|
self.assertEqual(wizard.fiscal_position_ids.type, "new")
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
self.assertEqual(wizard.state, 'done')
|
self.assertEqual(wizard.state, "done")
|
||||||
self.assertEqual(wizard.new_taxes, 1)
|
self.assertEqual(wizard.new_taxes, 1)
|
||||||
self.assertEqual(wizard.new_accounts, 1)
|
self.assertEqual(wizard.new_accounts, 1)
|
||||||
self.assertEqual(wizard.new_fps, 1)
|
self.assertEqual(wizard.new_fps, 1)
|
||||||
self.assertTrue(wizard.log)
|
self.assertTrue(wizard.log)
|
||||||
new_tax = self.env['account.tax'].search([
|
new_tax = self.env["account.tax"].search(
|
||||||
('name', '=', new_tax_tmpl.name),
|
[("name", "=", new_tax_tmpl.name), ("company_id", "=", self.company.id)]
|
||||||
('company_id', '=', self.company.id),
|
)
|
||||||
])
|
|
||||||
self.assertTrue(new_tax)
|
self.assertTrue(new_tax)
|
||||||
new_account = self.env['account.account'].search([
|
new_account = self.env["account.account"].search(
|
||||||
('code', '=', new_account_tmpl.code),
|
[("code", "=", new_account_tmpl.code), ("company_id", "=", self.company.id)]
|
||||||
('company_id', '=', self.company.id),
|
)
|
||||||
])
|
|
||||||
self.assertTrue(new_account)
|
self.assertTrue(new_account)
|
||||||
fp = self.env['account.fiscal.position'].search([
|
fp = self.env["account.fiscal.position"].search(
|
||||||
('name', '=', new_fp.name),
|
[("name", "=", new_fp.name), ("company_id", "=", self.company.id)]
|
||||||
('company_id', '=', self.company.id),
|
)
|
||||||
])
|
|
||||||
self.assertTrue(fp)
|
self.assertTrue(fp)
|
||||||
self.assertTrue(fp.tax_ids)
|
self.assertTrue(fp.tax_ids)
|
||||||
self.assertTrue(fp.account_ids)
|
self.assertTrue(fp.account_ids)
|
||||||
@ -233,7 +234,7 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
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 = [
|
self.account_template.tag_ids = [
|
||||||
(6, 0, [self.account_tag_1.id, self.account_tag_2.id]),
|
(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
|
||||||
@ -242,16 +243,16 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertTrue(wizard.tax_ids)
|
self.assertTrue(wizard.tax_ids)
|
||||||
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'updated')
|
self.assertEqual(wizard.tax_ids.type, "updated")
|
||||||
self.assertTrue(wizard.account_ids)
|
self.assertTrue(wizard.account_ids)
|
||||||
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
||||||
self.assertEqual(wizard.account_ids.type, 'updated')
|
self.assertEqual(wizard.account_ids.type, "updated")
|
||||||
self.assertTrue(wizard.fiscal_position_ids)
|
self.assertTrue(wizard.fiscal_position_ids)
|
||||||
self.assertTrue(wizard.fiscal_position_ids.type, 'updated')
|
self.assertTrue(wizard.fiscal_position_ids.type, "updated")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
wizard.fiscal_position_ids.fiscal_position_id, self.fp_template,
|
wizard.fiscal_position_ids.fiscal_position_id, self.fp_template
|
||||||
)
|
)
|
||||||
self.assertEqual(wizard.fiscal_position_ids.type, 'updated')
|
self.assertEqual(wizard.fiscal_position_ids.type, "updated")
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
self.assertEqual(wizard.updated_taxes, 1)
|
self.assertEqual(wizard.updated_taxes, 1)
|
||||||
self.assertEqual(wizard.updated_accounts, 1)
|
self.assertEqual(wizard.updated_accounts, 1)
|
||||||
@ -272,18 +273,15 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
self.fp_template.note = "Test note 2"
|
self.fp_template.note = "Test note 2"
|
||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
wizard.tax_field_ids -= self.env['ir.model.fields'].search([
|
wizard.tax_field_ids -= self.env["ir.model.fields"].search(
|
||||||
('model', '=', 'account.tax.template'),
|
[("model", "=", "account.tax.template"), ("name", "=", "description")]
|
||||||
('name', '=', 'description'),
|
)
|
||||||
])
|
wizard.account_field_ids -= self.env["ir.model.fields"].search(
|
||||||
wizard.account_field_ids -= self.env['ir.model.fields'].search([
|
[("model", "=", "account.account.template"), ("name", "=", "name")]
|
||||||
('model', '=', 'account.account.template'),
|
)
|
||||||
('name', '=', 'name'),
|
wizard.fp_field_ids -= self.env["ir.model.fields"].search(
|
||||||
])
|
[("model", "=", "account.fiscal.position.template"), ("name", "=", "note")]
|
||||||
wizard.fp_field_ids -= self.env['ir.model.fields'].search([
|
)
|
||||||
('model', '=', 'account.fiscal.position.template'),
|
|
||||||
('name', '=', 'note'),
|
|
||||||
])
|
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertFalse(wizard.tax_ids)
|
self.assertFalse(wizard.tax_ids)
|
||||||
self.assertFalse(wizard.account_ids)
|
self.assertFalse(wizard.account_ids)
|
||||||
@ -298,35 +296,45 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertTrue(wizard.tax_ids)
|
self.assertTrue(wizard.tax_ids)
|
||||||
self.assertEqual(wizard.tax_ids.update_tax_id, new_tax)
|
self.assertEqual(wizard.tax_ids.update_tax_id, new_tax)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'deleted')
|
self.assertEqual(wizard.tax_ids.type, "deleted")
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
self.assertEqual(wizard.deleted_taxes, 1)
|
self.assertEqual(wizard.deleted_taxes, 1)
|
||||||
self.assertFalse(new_tax.active)
|
self.assertFalse(new_tax.active)
|
||||||
wizard.unlink()
|
wizard.unlink()
|
||||||
# Errors on account update
|
# Errors on account update
|
||||||
self.account_template.currency_id = self.ref('base.USD')
|
self.account_template.currency_id = self.ref("base.USD")
|
||||||
self.env['account.move'].create({
|
self.env["account.move"].create(
|
||||||
'name': 'Test move',
|
{
|
||||||
'journal_id': self.env['account.journal'].search([
|
"name": "Test move",
|
||||||
('company_id', '=', self.company.id),
|
"journal_id": self.env["account.journal"]
|
||||||
], limit=1).id,
|
.search([("company_id", "=", self.company.id)], limit=1)
|
||||||
'date': fields.Date.today(),
|
.id,
|
||||||
'line_ids': [
|
"date": fields.Date.today(),
|
||||||
(0, 0, {
|
"line_ids": [
|
||||||
'account_id': self.account.id,
|
(
|
||||||
'name': 'Test move line',
|
0,
|
||||||
'debit': 10,
|
0,
|
||||||
'credit': 0,
|
{
|
||||||
'currency_id': self.ref('base.EUR'),
|
"account_id": self.account.id,
|
||||||
}),
|
"name": "Test move line",
|
||||||
(0, 0, {
|
"debit": 10,
|
||||||
'account_id': self.account.id,
|
"credit": 0,
|
||||||
'name': 'Test move line2',
|
"currency_id": self.ref("base.EUR"),
|
||||||
'debit': 0,
|
},
|
||||||
'credit': 10,
|
),
|
||||||
}),
|
(
|
||||||
]
|
0,
|
||||||
})
|
0,
|
||||||
|
{
|
||||||
|
"account_id": self.account.id,
|
||||||
|
"name": "Test move line2",
|
||||||
|
"debit": 0,
|
||||||
|
"credit": 10,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
self.tax_template.description = "Other description"
|
self.tax_template.description = "Other description"
|
||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
@ -343,12 +351,12 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
# Errors on account_creation
|
# Errors on account_creation
|
||||||
self.account_template.currency_id = False
|
self.account_template.currency_id = False
|
||||||
new_account_tmpl_2 = self._create_account_tmpl(
|
new_account_tmpl_2 = self._create_account_tmpl(
|
||||||
'Test account 3', '444444', self.account_type, self.chart_template,
|
"Test account 3", "444444", self.account_type, self.chart_template
|
||||||
)
|
)
|
||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertEqual(wizard.account_ids.type, 'new')
|
self.assertEqual(wizard.account_ids.type, "new")
|
||||||
new_account_tmpl_2.code = '333333' # Trick the code for forcing error
|
new_account_tmpl_2.code = "333333" # Trick the code for forcing error
|
||||||
with self.assertRaises(Exception):
|
with self.assertRaises(Exception):
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
wizard.continue_on_errors = True
|
wizard.continue_on_errors = True
|
||||||
@ -366,12 +374,13 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'updated')
|
self.assertEqual(wizard.tax_ids.type, "updated")
|
||||||
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
||||||
self.assertEqual(wizard.account_ids.type, 'updated')
|
self.assertEqual(wizard.account_ids.type, "updated")
|
||||||
self.assertTrue(wizard.fiscal_position_ids.type, 'updated')
|
self.assertTrue(wizard.fiscal_position_ids.type, "updated")
|
||||||
self.assertEqual(wizard.fiscal_position_ids.fiscal_position_id,
|
self.assertEqual(
|
||||||
self.fp_template)
|
wizard.fiscal_position_ids.fiscal_position_id, self.fp_template
|
||||||
|
)
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
self.assertEqual(wizard.updated_taxes, 1)
|
self.assertEqual(wizard.updated_taxes, 1)
|
||||||
self.assertEqual(wizard.updated_accounts, 1)
|
self.assertEqual(wizard.updated_accounts, 1)
|
||||||
@ -392,12 +401,13 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'updated')
|
self.assertEqual(wizard.tax_ids.type, "updated")
|
||||||
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
||||||
self.assertEqual(wizard.account_ids.type, 'updated')
|
self.assertEqual(wizard.account_ids.type, "updated")
|
||||||
self.assertTrue(wizard.fiscal_position_ids.type, 'updated')
|
self.assertTrue(wizard.fiscal_position_ids.type, "updated")
|
||||||
self.assertEqual(wizard.fiscal_position_ids.fiscal_position_id,
|
self.assertEqual(
|
||||||
self.fp_template)
|
wizard.fiscal_position_ids.fiscal_position_id, self.fp_template
|
||||||
|
)
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
self.assertEqual(wizard.updated_taxes, 1)
|
self.assertEqual(wizard.updated_taxes, 1)
|
||||||
self.assertEqual(wizard.updated_accounts, 1)
|
self.assertEqual(wizard.updated_accounts, 1)
|
||||||
@ -412,7 +422,7 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
||||||
self.assertEqual(wizard.account_ids.type, 'updated')
|
self.assertEqual(wizard.account_ids.type, "updated")
|
||||||
wizard.action_update_records()
|
wizard.action_update_records()
|
||||||
self.assertEqual(wizard.updated_accounts, 1)
|
self.assertEqual(wizard.updated_accounts, 1)
|
||||||
self.assertEqual(self.account.code, self.account_template.code)
|
self.assertEqual(self.account.code, self.account_template.code)
|
||||||
@ -426,12 +436,13 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'updated')
|
self.assertEqual(wizard.tax_ids.type, "updated")
|
||||||
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
||||||
self.assertEqual(wizard.account_ids.type, 'updated')
|
self.assertEqual(wizard.account_ids.type, "updated")
|
||||||
self.assertTrue(wizard.fiscal_position_ids.type, 'updated')
|
self.assertTrue(wizard.fiscal_position_ids.type, "updated")
|
||||||
self.assertEqual(wizard.fiscal_position_ids.fiscal_position_id,
|
self.assertEqual(
|
||||||
self.fp_template)
|
wizard.fiscal_position_ids.fiscal_position_id, self.fp_template
|
||||||
|
)
|
||||||
# There is no XML-ID
|
# There is no XML-ID
|
||||||
self.assertFalse(list(self.tax.get_xml_id().values())[0])
|
self.assertFalse(list(self.tax.get_xml_id().values())[0])
|
||||||
self.assertFalse(list(self.account.get_xml_id().values())[0])
|
self.assertFalse(list(self.account.get_xml_id().values())[0])
|
||||||
@ -457,12 +468,13 @@ class TestAccountChartUpdate(common.HttpCase):
|
|||||||
wizard = self.wizard_obj.create(self.wizard_vals)
|
wizard = self.wizard_obj.create(self.wizard_vals)
|
||||||
wizard.action_find_records()
|
wizard.action_find_records()
|
||||||
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
self.assertEqual(wizard.tax_ids.tax_id, self.tax_template)
|
||||||
self.assertEqual(wizard.tax_ids.type, 'updated')
|
self.assertEqual(wizard.tax_ids.type, "updated")
|
||||||
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
self.assertEqual(wizard.account_ids.account_id, self.account_template)
|
||||||
self.assertEqual(wizard.account_ids.type, 'updated')
|
self.assertEqual(wizard.account_ids.type, "updated")
|
||||||
self.assertTrue(wizard.fiscal_position_ids.type, 'updated')
|
self.assertTrue(wizard.fiscal_position_ids.type, "updated")
|
||||||
self.assertEqual(wizard.fiscal_position_ids.fiscal_position_id,
|
self.assertEqual(
|
||||||
self.fp_template)
|
wizard.fiscal_position_ids.fiscal_position_id, self.fp_template
|
||||||
|
)
|
||||||
# There is no XML-ID
|
# There is no XML-ID
|
||||||
self.assertFalse(list(self.tax.get_xml_id().values())[0])
|
self.assertFalse(list(self.tax.get_xml_id().values())[0])
|
||||||
self.assertFalse(list(self.account.get_xml_id().values())[0])
|
self.assertFalse(list(self.account.get_xml_id().values())[0])
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user