mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add option to filter stockitems by "external" location status (#4407)
* Add option to filter stockitems by "external" location status * flake fix
This commit is contained in:
parent
8b7e41baf9
commit
ed7d2e1262
@ -421,6 +421,16 @@ class StockFilter(rest_filters.FilterSet):
|
||||
else:
|
||||
return queryset.exclude(StockItem.EXPIRED_FILTER)
|
||||
|
||||
external = rest_filters.BooleanFilter(label=_('External Location'), method='filter_external')
|
||||
|
||||
def filter_external(self, queryset, name, value):
|
||||
"""Filter by whether or not the stock item is located in an external location"""
|
||||
|
||||
if str2bool(value):
|
||||
return queryset.filter(location__external=True)
|
||||
else:
|
||||
return queryset.exclude(location__external=True)
|
||||
|
||||
in_stock = rest_filters.BooleanFilter(label='In Stock', method='filter_in_stock')
|
||||
|
||||
def filter_in_stock(self, queryset, name, value):
|
||||
|
@ -292,6 +292,10 @@ function getAvailableTableFilters(tableKey) {
|
||||
type: 'date',
|
||||
title: '{% trans "Expiry Date after" %}',
|
||||
},
|
||||
external: {
|
||||
type: 'bool',
|
||||
title: '{% trans "External Location" %}',
|
||||
}
|
||||
};
|
||||
|
||||
// Optional filters if stock expiry functionality is enabled
|
||||
|
Loading…
Reference in New Issue
Block a user