Add stock item filtering by serial number range

This commit is contained in:
Oliver Walters 2020-05-26 11:49:48 +10:00
parent 046a00026c
commit 4cbf2099fa

View File

@ -488,6 +488,19 @@ 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: