From 46c4e6fc56518f00d69892e7e715b8877b26e201 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 11 Mar 2021 08:19:33 +0000 Subject: [PATCH] [FIX] sale: Wrong untaxed_amount_to_invoice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Let's consider an included tax T (10%) and a product P (11€) with invoicing policy based on delivery - Create a sale order SO with one line L with 2 P and T - Confirm SO Bug: The untaxed_amount_to_invoice was 20€ on L instead 0€ The untaxed_amount_to_invoice must be 20€ when the delivery is processed opw:2457660 opw:2457660 closes odoo/odoo#67682 X-original-commit: d6ed6b9fa204fcfcabf1c1c330b5ae8ada34744c Signed-off-by: Simon Goffin (sig) --- addons/sale/models/sale.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 38f262db761..eb135fecc20 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -1562,10 +1562,8 @@ class SaleOrderLine(models.Model): # amount and not zero. Since we compute untaxed amount, we can use directly the price # reduce (to include discount) without using `compute_all()` method on taxes. price_subtotal = 0.0 - if line.product_id.invoice_policy == 'delivery': - price_subtotal = line.price_reduce * line.qty_delivered - else: - price_subtotal = line.price_reduce * line.product_uom_qty + umo_qty_to_consider = line.qty_delivered if line.product_id.invoice_policy == 'delivery' else line.product_uom_qty + price_subtotal = line.price_reduce * umo_qty_to_consider if len(line.tax_id.filtered(lambda tax: tax.price_include)) > 0: # As included taxes are not excluded from the computed subtotal, `compute_all()` method # has to be called to retrieve the subtotal without them. @@ -1573,7 +1571,7 @@ class SaleOrderLine(models.Model): price_subtotal = line.tax_id.compute_all( line.price_reduce, currency=line.order_id.currency_id, - quantity=line.product_uom_qty, + quantity=umo_qty_to_consider, product=line.product_id, partner=line.order_id.partner_shipping_id)['total_excluded']