[FIX] sale: Wrong display of taxes in PRO-FORMA

Steps to reproduce the bug:

-Create a tax of 21% tax included but don't select the "affect base" checkbox.
-Create another tax of 5.2% (no tax include)
-Create a sale order with a line that has a unit price of 121 and both taxes.
Notice that the total amount is: 126.2 (100 base amount + 21 from 21% tax + 5.2 from 5.2 tax)
-Click on "Print the proforma invoice"

Bug:

The total amount was still 126.2 and base=100, however taxes were wrong, there were 21 for the 21% tax
and 6.29 instead of 5.2 for the 5.2 tax.

Back-port of this commit: f50a08bc3d

Forward up to saas-15

opw:1819882
This commit is contained in:
Goffin Simon
2018-03-29 16:21:25 +02:00
parent 15c3cbab55
commit 2b4bc45e58
+4 -9
View File
@@ -502,19 +502,14 @@ class SaleOrder(models.Model):
res = {}
currency = self.currency_id or self.company_id.currency_id
for line in self.order_line:
base_tax = 0
price_reduce = line.price_unit * (1.0 - line.discount / 100.0)
taxes = line.tax_id.compute_all(price_reduce, quantity=line.product_uom_qty, product=line.product_id, partner=self.partner_shipping_id)['taxes']
for tax in line.tax_id:
group = tax.tax_group_id
res.setdefault(group, 0.0)
# FORWARD-PORT UP TO SAAS-17
price_reduce = line.price_unit * (1.0 - line.discount / 100.0)
taxes = tax.compute_all(price_reduce + base_tax, quantity=line.product_uom_qty,
product=line.product_id, partner=self.partner_shipping_id)['taxes']
for t in taxes:
res[group] += t['amount']
if tax.include_base_amount:
base_tax += tax.compute_all(price_reduce + base_tax, quantity=1, product=line.product_id,
partner=self.partner_shipping_id)['taxes'][0]['amount']
if t['id'] == tax.id or t['id'] in tax.children_tax_ids.ids:
res[group] += t['amount']
res = sorted(res.items(), key=lambda l: l[0].sequence)
res = map(lambda l: (l[0].name, l[1]), res)
return res