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:
Oliver 2023-02-25 07:19:41 +11:00 committed by GitHub
parent 8b7e41baf9
commit ed7d2e1262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -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):

View File

@ -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