From c1224048ad6c8b762d71a74354415867fb75e0e8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 16 May 2019 21:01:34 +1000 Subject: [PATCH] Add ability to filter stock by supplier --- InvenTree/stock/api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 29b151ddbf..86b5f84c67 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -242,6 +242,7 @@ class StockList(generics.ListCreateAPIView): Additional query parameters are available: - location: Filter stock by location - category: Filter by parts belonging to a certain category + - supplier: Filter by supplier """ def get_queryset(self): @@ -275,6 +276,12 @@ class StockList(generics.ListCreateAPIView): except PartCategory.DoesNotExist: pass + # Filter by supplier + supplier_id = self.request.query_params.get('supplier', None) + + if supplier_id: + stock_list = stock_list.filter(supplier_part__supplier=supplier_id) + return stock_list serializer_class = StockItemSerializer