Add "sent_to_customer" filter

This commit is contained in:
Oliver Walters 2020-08-09 21:10:21 +10:00
parent 502702b3bc
commit 0da9e0f834
2 changed files with 16 additions and 0 deletions

View File

@ -477,6 +477,17 @@ class StockList(generics.ListCreateAPIView):
if customer:
queryset = queryset.filter(customer=customer)
# Filter if items have been sent to a customer (any customer)
sent_to_customer = params.get('sent_to_customer', None)
if sent_to_customer is not None:
sent_to_customer = str2bool(sent_to_customer)
if sent_to_customer:
queryset = queryset.exclude(customer=None)
else:
queryset = queryset.filter(customer=None)
# Filter by "serialized" status?
serialized = params.get('serialized', None)

View File

@ -57,6 +57,11 @@ function getAvailableTableFilters(tableKey) {
title: '{% trans "In Stock" %}',
description: '{% trans "Show items which are in stock" %}',
},
sent_to_customer: {
type: 'bool',
title: '{% trans "Sent to customer" %}',
description: '{% trans "Show items which have been assigned to a customer" %}',
},
serialized: {
type: 'bool',
title: '{% trans "Is Serialized" %}',