From 5a262f7b795a6df54e2045c666f90ff23847a11a Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 30 Oct 2020 14:29:31 +0000 Subject: [PATCH] [FIX] sale_stock: prevent incorrect computation of kits - Activate UoM - Create 3 products: AB, A & B - Create a kit BoM for AB - 1 units of A - 1 kg of B - Sell 1 unit of AB, confirm The error "The unit of measure Units defined on the order line doesn't belong to the same category...". This happens because `_compute_quantity` is called on `stock.moves` related to different products. As a first step, we simply keep only the moves of the same product, meaning that the `qty_available_today` and `free_qty_today` are not supported for kits. opw-2372676 closes odoo/odoo#61071 X-original-commit: 15368c6d1316d43b1591b88e4d5786d86403f8a1 Signed-off-by: Nicolas Martinelli (nim) --- addons/sale_stock/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index e856e9a1732..6020a35e6ec 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -305,7 +305,7 @@ class SaleOrderLine(models.Model): for line in self.filtered(lambda l: l.state == 'sale'): if not line.display_qty_widget: continue - moves = line.move_ids + moves = line.move_ids.filtered(lambda m: m.product_id == line.product_id) line.forecast_expected_date = max(moves.filtered("forecast_expected_date").mapped("forecast_expected_date"), default=False) line.qty_available_today = 0 line.free_qty_today = 0