From 723d332339aa8006f1c29a017e7fae44cb7db9f9 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 17 Feb 2020 13:37:10 +0000 Subject: [PATCH] [FIX] stock: MTSO with previous picking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Set the rule 'WH: Stock → Customers (MTO)' with: Supply Method: Take From Stock, if unavailable, Trigger Another Rule - Create product A Routes MTO, Buy Add 3 Units in 'Stock' Set a supplier - Create a SO for 5 Units, validate => a RFQ for 5 units is created - Create a SO for 2 Units, validate 2 Units are added to the RFQ, although there is enough in stock. This is because we take into account the 'Forecasted Quantity' instead of the 'Free To Use Quantity'. closes odoo/odoo#45590 X-original-commit: 00993a136052487ea43bed0e59bb7bbc54113bac Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/models/stock_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_rule.py b/addons/stock/models/stock_rule.py index faa4d699876..899343db755 100644 --- a/addons/stock/models/stock_rule.py +++ b/addons/stock/models/stock_rule.py @@ -233,7 +233,7 @@ class StockRule(models.Model): forecasted_qties_by_loc = {} for location, product_ids in mtso_products_by_locations.items(): products = self.env['product.product'].browse(product_ids).with_context(location=location.id) - forecasted_qties_by_loc[location] = {product.id: product.virtual_available for product in products} + forecasted_qties_by_loc[location] = {product.id: product.free_qty for product in products} # Prepare the move values, adapt the `procure_method` if needed. for procurement, rule in procurements: