From 56a8ea9422fe4a2e768f6ef351a0f9c5ad19c3d0 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 1 Apr 2020 12:47:34 +0000 Subject: [PATCH] [FIX] sale_stock: UoM of forecast stock - Activate Multi UoM - Create a product P with 120 Units in stock - Create a SO for 1 Dozen 120 Dozens are expected in the forecast widget instead of 10 Dozens. This happens because the various product quantities are always expressed in the product UoM: https://github.com/odoo/odoo/blob/c95fad77ea5b4663130e256f76031560171f09e6/addons/stock/models/product.py#L190 We add a conversion when necessary. opw-2224335 closes odoo/odoo#48885 X-original-commit: 39eab482c765ce0404c2c689aa522a023cac284e Signed-off-by: Nicolas Martinelli (nim) --- addons/sale_stock/models/sale_order.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 9f10ae4bb9f..d5f385bdbf1 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -317,6 +317,10 @@ class SaleOrderLine(models.Model): line.qty_available_today = qty_available_today - qty_processed_per_product[line.product_id.id] line.free_qty_today = free_qty_today - qty_processed_per_product[line.product_id.id] line.virtual_available_at_date = virtual_available_at_date - qty_processed_per_product[line.product_id.id] + if line.product_uom and line.product_id.uom_id and line.product_uom != line.product_id.uom_id: + line.qty_available_today = line.product_id.uom_id._compute_quantity(line.qty_available_today, line.product_uom) + line.free_qty_today = line.product_id.uom_id._compute_quantity(line.free_qty_today, line.product_uom) + line.virtual_available_at_date = line.product_id.uom_id._compute_quantity(line.virtual_available_at_date, line.product_uom) qty_processed_per_product[line.product_id.id] += line.product_uom_qty treated |= lines remaining = (self - treated)