From 52339997a219ab663c4ddfa83164c079e5fe87ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 6 Apr 2009 10:33:20 +0200 Subject: [PATCH] Call apply tax rule with empty tax Handle list return for apply --- purchase.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/purchase.py b/purchase.py index 3ae3e7643b..25dbdf314e 100644 --- a/purchase.py +++ b/purchase.py @@ -983,17 +983,23 @@ class PurchaseLine(ModelSQL, ModelView): res['unit_price'] = product_obj.get_purchase_price(cursor, user, [product.id], vals.get('quantity', 0), context=ctx2)[product.id] res['taxes'] = [] + pattern = self._get_tax_rule_pattern(cursor, user, party, vals, + context=context) for tax in product.supplier_taxes_used: if party and party.supplier_tax_rule: - pattern = self._get_tax_rule_pattern(cursor, user, party, - vals, context=context) - tax_id = tax_rule_obj.apply(cursor, user, + tax_ids = tax_rule_obj.apply(cursor, user, party.supplier_tax_rule, tax, pattern, context=context) - if tax_id: - res['taxes'].append(tax_id) + if tax_ids: + res['taxes'].extend(tax_ids) continue res['taxes'].append(tax.id) + if party and party.supplier_tax_rule: + tax_ids = tax_rule_obj.apply(cursor, user, + party.supplier_tax_rule, False, pattern, + context=context) + if tax_ids: + res['taxes'].extend(tax_ids) if not vals.get('description'): res['description'] = product_obj.browse(cursor, user, product.id,