From 3e5d4a173cb2969cad1cb8bb723a4d57eb837ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Tue, 7 Jan 2014 12:48:24 +0100 Subject: [PATCH] [IMP] attempt to match tax code on code if no match on name was found --- account_chart_update/__openerp__.py | 11 ++++++++--- account_chart_update/wizard/wizard_chart_update.py | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/account_chart_update/__openerp__.py b/account_chart_update/__openerp__.py index 860606f0..fc619522 100644 --- a/account_chart_update/__openerp__.py +++ b/account_chart_update/__openerp__.py @@ -26,12 +26,17 @@ { 'name': "Detect changes and update the Account Chart from a template", - 'version': "1.0", + 'version': "1.1", 'author': "Zikzakmedia SL", 'website': "www.zikzakmedia.com", 'depends': ["account"], 'category': "Generic Modules/Accounting", - 'contributors': ['Joaquín Gutierrez', 'Pedro M. Baeza', 'invitu'], + 'contributors': [ + 'Joaquín Gutierrez', + 'Pedro M. Baeza', + 'invitu', + 'Stéphane Bidoul', + ], 'description': """ Adds a wizard to update a company account chart from a chart template. ====================================================================== @@ -60,7 +65,7 @@ Any problem found while updating will be shown on the last step. "account", "base", ], - "demo" : [], + "demo": [], "data": [ 'wizard/wizard_chart_update_view.xml', ], diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index 604836ab..7389cbf2 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -267,6 +267,15 @@ class wizard_update_charts_accounts(orm.TransientModel): ('name', '=', tax_code_name), ('company_id', '=', wizard.company_id.id) ]) + 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_codes.search(cr, uid, [ + ('code', '=', tax_code_code), + ('company_id', '=', wizard.company_id.id) + ]) if tax_code_ids: tax_code_template_mapping[ tax_code_template.id] = tax_code_ids[0]