From e76fe2449c337087a6668a4d8bd5f9c08166a539 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 24 Jul 2017 10:18:50 +0200 Subject: [PATCH] [FIX] sale: taxes on report - Create a tax using the tax template 'GST + QST for sales' - Create a SO with the following lines: Product 1 100 Units @ 0.1 Product 2 2000 Units @ 10.334 Product 3 2000 Units @ 10.334 Product 4 5000 Units @ 0.1 Product 5 1500 Units @ 0.1 - The totals are: Amount without taxes: 41996.00 Taxes: 6288.90 When printed, the quotation gives: Amount without taxes: 41996.00 Taxes: 6286.52 This is due to the method `_get_tax_amount_by_group`, which is using `line.price_reduce` for tax computation. Since it is a Monetary field, it is automatically rounded to the currency precision, while it should be rounded with the same precision as `price_unit`. To avoid breaking overrides, changing the field type is done in master branch. Introduced in 99743cc4aa4d5b52b77a3a38650ef2d7a54ab984 opw-752487 --- addons/sale/models/sale.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index d512037e445..0499cb07f44 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -506,12 +506,14 @@ class SaleOrder(models.Model): for tax in line.tax_id: group = tax.tax_group_id res.setdefault(group, 0.0) - taxes = tax.compute_all(line.price_reduce + base_tax, quantity=line.product_uom_qty, + # 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(line.price_reduce + base_tax, quantity=1, product=line.product_id, + base_tax += tax.compute_all(price_reduce + base_tax, quantity=1, product=line.product_id, partner=self.partner_shipping_id)['taxes'][0]['amount'] res = sorted(res.items(), key=lambda l: l[0].sequence) res = map(lambda l: (l[0].name, l[1]), res)