implement purchase price filter for stock table

Closes #1717
This commit is contained in:
Matthias 2021-07-02 16:31:42 +02:00
parent ded0fb5353
commit 9c8717574a
2 changed files with 18 additions and 1 deletions

View File

@ -858,6 +858,18 @@ class StockList(generics.ListCreateAPIView):
print("After error:", str(updated_after)) print("After error:", str(updated_after))
pass pass
# Filter stock items which have a purchase price set
has_purchase_price = params.get('has_purchase_price', None)
if has_purchase_price is not None:
has_purchase_price = str2bool(has_purchase_price)
if has_purchase_price:
queryset = queryset.exclude(purchase_price=None)
else:
queryset = queryset.filter(purchase_price=None)
# Optionally, limit the maximum number of returned results # Optionally, limit the maximum number of returned results
max_results = params.get('max_results', None) max_results = params.get('max_results', None)

View File

@ -205,7 +205,12 @@ function getAvailableTableFilters(tableKey) {
batch: { batch: {
title: '{% trans "Batch" %}', title: '{% trans "Batch" %}',
description: '{% trans "Batch code" %}', description: '{% trans "Batch code" %}',
} },
has_purchase_price: {
type: 'bool',
title: '{% trans "Has purchase price" %}',
description: '{% trans "Show stock items which have a purchase price set" %}',
},
}; };
} }