[FIX] stock: MTSO with previous picking

- 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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-02-18 09:38:37 +00:00
parent 0660a9c015
commit 723d332339
+1 -1
View File
@@ -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: