From 5727e27ae61eeca77d490ded80ec8ec372dbbad9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 28 Apr 2020 08:44:10 +1000 Subject: [PATCH] Filter by 'in stock' items when auto-allocating to build --- InvenTree/build/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 8a00f0ad63..f5dd359a0b 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -189,7 +189,11 @@ class Build(MPTTModel): # How many parts required for this build? q_required = item.quantity * self.quantity - stock = StockItem.objects.filter(part=item.sub_part) + # Grab a list of StockItem objects which are "in stock" + stock = StockItem.objects.filter(StockItem.IN_STOCK_FILTER) + + # Filter by part reference + stock = stock.filter(part=item.sub_part) # Ensure that the available stock items are in the correct location if self.take_from is not None: