2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-09 07:00:56 +00:00

Expose "is_allocated" parameter on StockItem API

This commit is contained in:
Oliver Walters
2020-04-22 10:11:40 +10:00
parent 12daf15406
commit 6dd79af0b6
7 changed files with 68 additions and 2 deletions

View File

@ -367,6 +367,17 @@ class StockList(generics.ListCreateAPIView):
# Filter out parts which are not actually "in stock"
stock_list = stock_list.filter(customer=None, belongs_to=None)
# Filter by 'allocated' patrs?
allocated = self.request.query_params.get('allocated', None)
if allocated is not None:
allocated = str2bool(allocated)
if allocated:
stock_list = stock_list.exclude(Q(sales_order_line=None))
else:
stock_list = stock_list.filter(Q(sales_order_line=None))
# Do we wish to filter by "active parts"
active = self.request.query_params.get('active', None)