[IMP] account_chart_update: search on code first to match tax codes

The tax code code should be more discriminant that the tax code name.
This commit is contained in:
Stéphane Bidoul
2014-12-24 00:23:39 +01:00
parent f29929ffbd
commit 4061e117d2

View File

@@ -356,21 +356,19 @@ class wizard_update_charts_accounts(orm.TransientModel):
# In other case
tax_code_obj = self.pool['account.tax.code']
root_tax_code_id = wizard.chart_template_id.tax_code_root_id.id
tax_code_name = ((tax_code_template.id == root_tax_code_id) and
wizard.company_id.name or tax_code_template.name)
tax_code_ids = tax_code_obj.search(cr, uid, [
('name', '=', tax_code_name),
('company_id', '=', wizard.company_id.id)
], context=context)
if not tax_code_ids:
# if we could not match no tax code template name,
# try to match on tax code template code, if any
tax_code_code = tax_code_template.code
if tax_code_code:
tax_code_ids = tax_code_obj.search(cr, uid, [
('code', '=', tax_code_code),
('company_id', '=', wizard.company_id.id)
], context=context)
tax_code_code = tax_code_template.code
if tax_code_code:
tax_code_ids = tax_code_obj.search(cr, uid, [
('code', '=', tax_code_code),
('company_id', '=', wizard.company_id.id)
], context=context)
if not tax_code_code or not tax_code_ids:
tax_code_name = ((tax_code_template.id == root_tax_code_id) and
wizard.company_id.name or tax_code_template.name)
tax_code_ids = tax_code_obj.search(cr, uid, [
('name', '=', tax_code_name),
('company_id', '=', wizard.company_id.id)
], context=context)
tax_code_templ_mapping[tax_code_template.id] = (tax_code_ids and
tax_code_ids[0] or
False)