Apply tax rule with empty taxes when creating purchase

issue6524
review35011002
This commit is contained in:
Sergi Almacellas Abellana
2017-06-07 13:54:01 +02:00
parent d62e0bf59a
commit adf81fc886
+6 -2
View File
@@ -470,17 +470,21 @@ class CreatePurchase(Wizard):
Decimal(1) / 10 ** Line.unit_price.digits[1])
line.unit_price = product_price
taxes = []
pattern = cls._get_tax_rule_pattern(line, purchase)
if line.product:
taxes = []
for tax in line.product.supplier_taxes_used:
if purchase.party and purchase.party.supplier_tax_rule:
pattern = cls._get_tax_rule_pattern(line, purchase)
tax_ids = purchase.party.supplier_tax_rule.apply(
tax, pattern)
if tax_ids:
taxes.extend(tax_ids)
continue
taxes.append(tax.id)
if purchase.party and purchase.party.supplier_tax_rule:
tax_ids = purchase.party.supplier_tax_rule.apply(None, pattern)
if tax_ids:
taxes.extend(tax_ids)
line.taxes = taxes
return line