2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

New part table filter on available stock

This commit is contained in:
Kálmán Rózsahegyi
2022-04-02 15:51:21 +02:00
parent d1d7db76cc
commit a9f7457c12
3 changed files with 23 additions and 2 deletions

View File

@ -798,6 +798,20 @@ class PartFilter(rest_filters.FilterSet):
return queryset
# unallocated_stock filter
unallocated_stock = rest_filters.BooleanFilter(label='Unallocated stock', method='filter_unallocated_stock')
def filter_unallocated_stock(self, queryset, name, value):
value = str2bool(value)
if value:
queryset = queryset.filter(Q(unallocated_stock__gt=0))
else:
queryset = queryset.filter(Q(unallocated_stock__lte=0))
return queryset
is_template = rest_filters.BooleanFilter()
assembly = rest_filters.BooleanFilter()