Skip to content

Commit

Permalink
[FIX] sale: Wrong display of taxes in PRO-FORMA
Browse files Browse the repository at this point in the history
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.

opw:1819882
  • Loading branch information
simongoffin committed Mar 20, 2018
1 parent c077ed8 commit f50a08b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions addons/sale/models/sale.py
Expand Up @@ -580,20 +580,16 @@ def _get_tax_amount_by_group(self):
self.ensure_one()
res = {}
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, {'amount': 0.0, 'base': 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]['amount'] += t['amount']
res[group]['base'] += t['base']
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:
res[group]['amount'] += t['amount']
res[group]['base'] += t['base']
res = sorted(res.items(), key=lambda l: l[0].sequence)
res = [(l[0].name, l[1]['amount'], l[1]['base'], len(res)) for l in res]
return res
Expand Down

0 comments on commit f50a08b

Please sign in to comment.