From 31f29e57425187fa0da83b08ecdd1116765e5e01 Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Wed, 2 Feb 2022 14:12:16 +0000 Subject: [PATCH] [FIX] purchase_stock: remove useless qty conversion in report To reproduce the issue: 1. In Settings, enable "Units of Measure" 2. Create a product P: - Type: Storable - Unit of Measure: Units - Purchase UoM: Dozens 3. Create a PO with 1 (Dozens) x P 4. Open the Forecasted Report of P Error: The value of "Requests for quotation" is 144, it should be 12. The quantity has been converted twice. OPW-2744195 closes odoo/odoo#84091 X-original-commit: 524a1c597fd409a488bb6af37aca8248727691c1 Signed-off-by: William Henrotin (whe) Signed-off-by: Adrien Widart --- addons/purchase_stock/report/report_stock_forecasted.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/purchase_stock/report/report_stock_forecasted.py b/addons/purchase_stock/report/report_stock_forecasted.py index 676698102f1..2492410fe4e 100644 --- a/addons/purchase_stock/report/report_stock_forecasted.py +++ b/addons/purchase_stock/report/report_stock_forecasted.py @@ -15,11 +15,7 @@ class ReplenishmentReport(models.AbstractModel): if warehouse_id: domain += [('order_id.picking_type_id.warehouse_id', '=', warehouse_id)] po_lines = self.env['purchase.order.line'].search(domain) - in_sum = 0 - if po_lines: - product_uom = po_lines[0].product_id.uom_id - quantities = po_lines.mapped(lambda line: line.product_uom._compute_quantity(line.product_uom_qty, product_uom)) - in_sum = sum(quantities) + in_sum = sum(po_lines.mapped('product_uom_qty')) res['draft_purchase_qty'] = in_sum res['draft_purchase_orders'] = po_lines.mapped("order_id").sorted(key=lambda po: po.name) res['draft_purchase_orders_matched'] = self.env.context.get('purchase_line_to_match_id') in po_lines.ids