From e3102900b61bb6657c13d756ed9286a37daabdd0 Mon Sep 17 00:00:00 2001 From: Oliver Walters <oliver.henry.walters@gmail.com> Date: Sat, 11 Apr 2020 14:41:07 +1000 Subject: [PATCH] Allow stock API to filter by parts which are not active --- InvenTree/stock/api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index ad989459ee..ebc5454d5b 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -410,8 +410,16 @@ class StockList(generics.ListCreateAPIView): # Start with all objects stock_list = super(StockList, self).get_queryset() + # Filter out parts which are not actually "in stock" stock_list = stock_list.filter(customer=None, belongs_to=None) + # Do we wish to filter by "active parts" + active = self.request.query_params.get('active', None) + + if active is not None: + active = str2bool(active) + stock_list = stock_list.filter(part__active=active) + # Does the client wish to filter by the Part ID? part_id = self.request.query_params.get('part', None)