From 4615fbc0d8e3fcc5256fb0d2f0335ab5bc036c02 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 12 May 2020 20:15:37 +1000 Subject: [PATCH 1/2] Abillty to filter stock list by serial number --- InvenTree/stock/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index f72f2590cc..404162a300 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -478,6 +478,12 @@ class StockList(generics.ListCreateAPIView): if sales_order: queryset = queryset.filter(sales_order=sales_order) + + # Filter by serial number? + serial_number = params.get('serial', None) + + if serial_number is not None: + queryset = queryset.filter(serial=serial_number) in_stock = self.request.query_params.get('in_stock', None) From 0851a925fb6a60ba05b4fb0f0559bb6c94ffd8ad Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 12 May 2020 20:18:28 +1000 Subject: [PATCH 2/2] Add ability to filter by whether the part is serialized or not --- InvenTree/stock/api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 404162a300..a56d4081d0 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -479,6 +479,17 @@ class StockList(generics.ListCreateAPIView): if sales_order: queryset = queryset.filter(sales_order=sales_order) + # Filter by "serialized" status? + serialized = params.get('serialized', None) + + if serialized is not None: + serialized = str2bool(serialized) + + if serialized: + queryset = queryset.exclude(serial=None) + else: + queryset = queryset.filter(serial=None) + # Filter by serial number? serial_number = params.get('serial', None)