mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user