mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add ability to filter stock by supplier
This commit is contained in:
parent
b4df96aaee
commit
c1224048ad
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user