From 2b4bc45e589de7a3d8934640ecc6ad82673ae707 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 29 Mar 2018 15:05:59 +0200 Subject: [PATCH] [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: f50a08bc3d53a1ccb7821c9dacd89c18f1215f15 Forward up to saas-15 opw:1819882 --- addons/sale/models/sale.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index ef74b8315b0..5d0dd9d83cd 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -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