[FIX+IMP] account_chart_update: Add consistency method
With this, we prevent lock due to infinite loop if children taxes are matched, but not the parent one and it's marked to be created.
This commit is contained in:
parent
d8644c16a3
commit
ad1b376b89
@ -7,7 +7,7 @@
|
||||
{
|
||||
"name": "Detect changes and update the Account Chart from a template",
|
||||
"summary": "Wizard to update a company's account chart from a template",
|
||||
"version": "13.0.1.0.1",
|
||||
"version": "13.0.1.0.2",
|
||||
"author": "Tecnativa, BCIM, Okia, Odoo Community Association (OCA)",
|
||||
"website": "http://github.com/OCA/account-financial-tools",
|
||||
"depends": ["account"],
|
||||
|
@ -319,8 +319,38 @@ class WizardUpdateChartsAccounts(models.TransientModel):
|
||||
self.state = "ready"
|
||||
return self._reopen()
|
||||
|
||||
def _check_consistency(self):
|
||||
"""Method for assuring consistency in operations before performing
|
||||
them. For now, implemented:
|
||||
|
||||
- If a parent tax is tried to be created, children taxes must be
|
||||
also included to be created.
|
||||
|
||||
TODO:
|
||||
|
||||
- Check that needed accounts in taxes/FPs are created at the same time.
|
||||
- Check that needed taxes in FPs are created at the same time.
|
||||
"""
|
||||
taxes2create = self.tax_ids.filtered(lambda x: x.type == "new")
|
||||
parents2create = taxes2create.filtered(lambda x: x.tax_id.children_tax_ids)
|
||||
for parent in parents2create:
|
||||
if bool(
|
||||
parent.tax_id.children_tax_ids - taxes2create.mapped("tax_id")
|
||||
): # some children taxes are not included to be added
|
||||
raise exceptions.UserError(
|
||||
_(
|
||||
"You have at least one parent tax template (%s) whose "
|
||||
"children taxes are not going to be created. Aborting "
|
||||
"as this will provoke an infinite loop. Please check "
|
||||
"if children have been matched, but not the parent one."
|
||||
)
|
||||
% parent.tax_id.name
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_update_records(self):
|
||||
"""Action that creates/updates/deletes the selected elements."""
|
||||
self._check_consistency()
|
||||
self = self.with_context(lang=self.lang)
|
||||
self.rejected_new_account_number = 0
|
||||
self.rejected_updated_account_number = 0
|
||||
|
Loading…
Reference in New Issue
Block a user