From 4cbf2099fafeba52ba2cf8fd0c2b6fec5fa8a298 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 26 May 2020 11:49:48 +1000 Subject: [PATCH] Add stock item filtering by serial number range --- InvenTree/stock/api.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 516edc5040..23d836b1e1 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -487,7 +487,20 @@ class StockList(generics.ListCreateAPIView): if serial_number is not None: queryset = queryset.filter(serial=serial_number) + + # Filter by range of serial numbers? + serial_number_gte = params.get('serial_gte', None) + serial_number_lte = params.get('serial_lte', None) + + if serial_number_gte is not None or serial_number_lte is not None: + queryset = queryset.exclude(serial=None) + + if serial_number_gte is not None: + queryset = queryset.filter(serial__gte=serial_number_gte) + if serial_number_lte is not None: + queryset = queryset.filter(serial__lte=serial_number_lte) + in_stock = params.get('in_stock', None) if in_stock is not None: