From 4dcf54e23f8b796396660fd7d4ab33897ef40e12 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 11 Oct 2016 15:27:19 +0200 Subject: [PATCH] [FIX] sale, purchase: tax computation Set the company rounding policy to "Round Globally". Create the following SO (or PO), with a 7 % excluded tax: - Qty Price - 880.000 5.79 - 120.000 4.36 - 28.000 2.88 - 68.000 11.09 - 35.000 5.20 - 35.000 5.32 The total tax on the SO is 477.48, while it is 477.50 on the invoice generated from the SO. Fixes #13687 opw-690090 --- addons/purchase/models/purchase.py | 4 ++-- addons/sale/models/sale.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 60e8322d17e..3abe4839024 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -509,7 +509,7 @@ class PurchaseOrderLine(models.Model): for line in self: taxes = line.taxes_id.compute_all(line.price_unit, line.order_id.currency_id, line.product_qty, product=line.product_id, partner=line.order_id.partner_id) line.update({ - 'price_tax': taxes['total_included'] - taxes['total_excluded'], + 'price_tax': sum(t.get('amount', 0.0) for t in taxes.get('taxes', [])), 'price_total': taxes['total_included'], 'price_subtotal': taxes['total_excluded'], }) @@ -567,7 +567,7 @@ class PurchaseOrderLine(models.Model): price_subtotal = fields.Monetary(compute='_compute_amount', string='Subtotal', store=True) price_total = fields.Monetary(compute='_compute_amount', string='Total', store=True) - price_tax = fields.Monetary(compute='_compute_amount', string='Tax', store=True) + price_tax = fields.Float(compute='_compute_amount', string='Tax', store=True) order_id = fields.Many2one('purchase.order', string='Order Reference', index=True, required=True, ondelete='cascade') account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 81f2d7fbb30..103ea11fc7a 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -557,7 +557,7 @@ class SaleOrderLine(models.Model): price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) taxes = line.tax_id.compute_all(price, line.order_id.currency_id, line.product_uom_qty, product=line.product_id, partner=line.order_id.partner_id) line.update({ - 'price_tax': taxes['total_included'] - taxes['total_excluded'], + 'price_tax': sum(t.get('amount', 0.0) for t in taxes.get('taxes', [])), 'price_total': taxes['total_included'], 'price_subtotal': taxes['total_excluded'], }) @@ -710,7 +710,7 @@ class SaleOrderLine(models.Model): price_unit = fields.Float('Unit Price', required=True, digits=dp.get_precision('Product Price'), default=0.0) price_subtotal = fields.Monetary(compute='_compute_amount', string='Subtotal', readonly=True, store=True) - price_tax = fields.Monetary(compute='_compute_amount', string='Taxes', readonly=True, store=True) + price_tax = fields.Float(compute='_compute_amount', string='Taxes', readonly=True, store=True) price_total = fields.Monetary(compute='_compute_amount', string='Total', readonly=True, store=True) price_reduce = fields.Monetary(compute='_get_price_reduce', string='Price Reduce', readonly=True, store=True)