From 5888531e5c1cf358dd37ab5e3bd78c4031f3bf96 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 6 Jan 2012 12:11:49 +0100 Subject: [PATCH] [FIX] account: fixed the generation of tax from sale and purchase rates in wizard bzr revid: qdp-launchpad@openerp.com-20120106111149-ztmuqg58980a0tu3 --- addons/account/account.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 6589ec724a2..432a90a653e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -3265,14 +3265,20 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_tax_temp = self.pool.get('account.tax.template') chart_template = obj_wizard.chart_template_id vals = {} + # get the ids of all the parents of the selected account chart template + current_chart_template = chart_template + all_parents = [current_chart_template.id] + while current_chart_template.parent_id: + current_chart_template = current_chart_template.parent_id + all_parents.append(current_chart_template.id) # create tax templates and tax code templates from purchase_tax_rate and sale_tax_rate fields if not chart_template.complete_tax_set: - if obj_wizard.sale_tax: - value = obj_wizard.sale_tax_rate - obj_tax_temp.write(cr, uid, [obj_wizard.sale_tax.id], {'amount': value/100.0, 'name': _('Tax %.2f%%') % value}) - if obj_wizard.purchase_tax: - value = obj_wizard.purchase_tax_rate - obj_tax_temp.write(cr, uid, [obj_wizard.purchase_tax.id], {'amount': value/100.0, 'name': _('Purchase Tax %.2f%%') % value}) + value = obj_wizard.sale_tax_rate + ref_tax_ids = obj_tax_temp.search(cr, uid, [('type_tax_use','in', ('sale','all')), ('chart_template_id', 'in', all_parents)], context=context, order="sequence, id desc", limit=1) + obj_tax_temp.write(cr, uid, ref_tax_ids, {'amount': value/100.0, 'name': _('Tax %.2f%%') % value}) + value = obj_wizard.purchase_tax_rate + ref_tax_ids = obj_tax_temp.search(cr, uid, [('type_tax_use','in', ('purchase','all')), ('chart_template_id', 'in', all_parents)], context=context, order="sequence, id desc", limit=1) + obj_tax_temp.write(cr, uid, ref_tax_ids, {'amount': value/100.0, 'name': _('Purchase Tax %.2f%%') % value}) return True def execute(self, cr, uid, ids, context=None):