From 0da9e0f8341575975123fef6c0ca196a8d574c02 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 9 Aug 2020 21:10:21 +1000 Subject: [PATCH] Add "sent_to_customer" filter --- InvenTree/stock/api.py | 11 +++++++++++ InvenTree/templates/js/table_filters.html | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 023b0c6c4e..b291a2cb5c 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -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) diff --git a/InvenTree/templates/js/table_filters.html b/InvenTree/templates/js/table_filters.html index aef430bf36..9050edba6f 100644 --- a/InvenTree/templates/js/table_filters.html +++ b/InvenTree/templates/js/table_filters.html @@ -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" %}',