mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
Adds ability to filter stockitem list by "has_batch" parmeter
This commit is contained in:
@ -410,6 +410,20 @@ class StockFilter(rest_filters.FilterSet):
|
||||
|
||||
return queryset
|
||||
|
||||
has_batch = rest_filters.BooleanFilter(label='Has batch code', method='filter_has_batch')
|
||||
|
||||
def filter_has_batch(self, queryset, name, value):
|
||||
"""
|
||||
Filter by whether the StockItem has a batch code (or not)
|
||||
"""
|
||||
|
||||
if str2bool(value):
|
||||
queryset = queryset.exclude(batch=None)
|
||||
else:
|
||||
queryset = queryset.filter(batch=None)
|
||||
|
||||
return queryset
|
||||
|
||||
installed = rest_filters.BooleanFilter(label='Installed in other stock item', method='filter_installed')
|
||||
|
||||
def filter_installed(self, queryset, name, value):
|
||||
|
Reference in New Issue
Block a user