mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56:45 +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:
|
else:
|
||||||
return queryset.exclude(StockItem.EXPIRED_FILTER)
|
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')
|
in_stock = rest_filters.BooleanFilter(label='In Stock', method='filter_in_stock')
|
||||||
|
|
||||||
def filter_in_stock(self, queryset, name, value):
|
def filter_in_stock(self, queryset, name, value):
|
||||||
|
@ -292,6 +292,10 @@ function getAvailableTableFilters(tableKey) {
|
|||||||
type: 'date',
|
type: 'date',
|
||||||
title: '{% trans "Expiry Date after" %}',
|
title: '{% trans "Expiry Date after" %}',
|
||||||
},
|
},
|
||||||
|
external: {
|
||||||
|
type: 'bool',
|
||||||
|
title: '{% trans "External Location" %}',
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Optional filters if stock expiry functionality is enabled
|
// Optional filters if stock expiry functionality is enabled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user