From 3ba8231733295686da253ca26017a12d9eac0938 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 28 Oct 2019 12:44:09 +0000 Subject: [PATCH] [FIX] purchase: Purchase report wrong qty_to_be_billed Steps to reproduce the bug: - Let's consider product P with purchase_method = 'purchase' - Create a purchase order PO and puchase 20 units of P to a vendor - Confirm PO and create a vendor bill VB the 20 units of P - Validate VB - The invoiced quantity on PO is 20 - Go to the Purchase report and analyse the qty_to_be_billed Bug: The qty_to_be_billed was still equal to 20 instead of 0 opw:2091264 closes odoo/odoo#39493 X-original-commit: b00febedef7826f593bb07c7896595ecce8cae32 Signed-off-by: Simon Goffin (sig) --- addons/purchase/report/purchase_report.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index ff69fee0e7f..08904bb3f85 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -92,7 +92,10 @@ class PurchaseReport(models.Model): sum(l.product_qty / line_uom.factor * product_uom.factor) as qty_ordered, sum(l.qty_received / line_uom.factor * product_uom.factor) as qty_received, sum(l.qty_invoiced / line_uom.factor * product_uom.factor) as qty_billed, - sum(l.product_qty / line_uom.factor * product_uom.factor) - sum(l.qty_received / line_uom.factor * product_uom.factor) as qty_to_be_billed + case when t.purchase_method = 'purchase' + then sum(l.product_qty / line_uom.factor * product_uom.factor) - sum(l.qty_invoiced / line_uom.factor * product_uom.factor) + else sum(l.qty_received / line_uom.factor * product_uom.factor) - sum(l.qty_invoiced / line_uom.factor * product_uom.factor) + end as qty_to_be_billed """ % self.env['res.currency']._select_companies_rates() return select_str @@ -135,6 +138,7 @@ class PurchaseReport(models.Model): line_uom.uom_type, line_uom.category_id, t.uom_id, + t.purchase_method, line_uom.id, product_uom.factor, partner.country_id,