From ceda0823060c4e6174a4eceac5274a44e1cc39ac Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Tue, 28 Aug 2018 11:21:29 +0200 Subject: [PATCH] Take draft PO quantities into account for forecast stock in mrp_mto_with_stock --- mrp_mto_with_stock/models/mrp_production.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mrp_mto_with_stock/models/mrp_production.py b/mrp_mto_with_stock/models/mrp_production.py index 73ad9012b..c2ae07cf8 100644 --- a/mrp_mto_with_stock/models/mrp_production.py +++ b/mrp_mto_with_stock/models/mrp_production.py @@ -122,6 +122,13 @@ class MrpProduction(models.Model): raise UserError('\n'.join(errors)) return True + # This method should be overriden in submodule to manage cases where + # we need to add quantities to the forecast quantity. Like draft purchase + # order, purchase request, etc... + @api.model + def _get_incoming_qty_waiting_validation(self, move): + return 0.0 + @api.multi def get_mto_qty_to_procure(self, move): self.ensure_one() @@ -130,6 +137,8 @@ class MrpProduction(models.Model): virtual_available = move_location.product_id.virtual_available qty_available = move.product_id.uom_id._compute_quantity( virtual_available, move.product_uom) + draft_incoming_qty = self._get_incoming_qty_waiting_validation(move) + qty_available += draft_incoming_qty if qty_available >= 0: return 0.0 else: