From 4061e117d2eaffaf1fdd6b7a165814c11198048b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 24 Dec 2014 00:23:39 +0100 Subject: [PATCH] [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. --- .../wizard/wizard_chart_update.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index 891faf0db..7f73695f0 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -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)