mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +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:
|
Additional query parameters are available:
|
||||||
- location: Filter stock by location
|
- location: Filter stock by location
|
||||||
- category: Filter by parts belonging to a certain category
|
- category: Filter by parts belonging to a certain category
|
||||||
|
- supplier: Filter by supplier
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@ -275,6 +276,12 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
except PartCategory.DoesNotExist:
|
except PartCategory.DoesNotExist:
|
||||||
pass
|
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
|
return stock_list
|
||||||
|
|
||||||
serializer_class = StockItemSerializer
|
serializer_class = StockItemSerializer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user