From 502702b3bc0e538d5ff5a57e0d0f20efb74cf1ca Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 9 Aug 2020 21:04:41 +1000 Subject: [PATCH 1/4] Add some more visual tags to the stock list --- InvenTree/templates/js/stock.html | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/InvenTree/templates/js/stock.html b/InvenTree/templates/js/stock.html index f06615f2f5..11cf6a94e3 100644 --- a/InvenTree/templates/js/stock.html +++ b/InvenTree/templates/js/stock.html @@ -1,4 +1,5 @@ {% load i18n %} +{% load status_codes %} /* Stock API functions * Requires api.js to be loaded first @@ -460,12 +461,26 @@ function loadStockTable(table, options) { var html = renderLink(val, `/stock/item/${row.pk}/`); if (row.allocated) { - html += ``; + html += ``; } + if (row.customer) { + html += ``; + } else if (row.build_order) { + html += ``; + } else if (row.sales_order) { + html += ``; + } + + // Special stock status codes + + // 65 = "REJECTED" + if (row.status == 65) { + html += ``; + } // 70 = "LOST" - if (row.status == 70) { - html += ``; + else if (row.status == 70) { + html += ``; } if (row.quantity <= 0) { From 0da9e0f8341575975123fef6c0ca196a8d574c02 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 9 Aug 2020 21:10:21 +1000 Subject: [PATCH 2/4] 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" %}', From 3336eb9f45ad20e4247a36d2b4323c4b1000a3d6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 9 Aug 2020 21:12:49 +1000 Subject: [PATCH 3/4] Default stock list behaviour is to only show in_stock items --- InvenTree/stock/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index b291a2cb5c..a10262ce9c 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -518,7 +518,8 @@ class StockList(generics.ListCreateAPIView): if serial_number_lte is not None: queryset = queryset.filter(serial__lte=serial_number_lte) - in_stock = params.get('in_stock', None) + # Filter by "in_stock" status (default behaviour is "True") + in_stock = params.get('in_stock', True) if in_stock is not None: in_stock = str2bool(in_stock) From cebba6909c7271b8e7524a032441f3e4d16eb48a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 9 Aug 2020 21:21:12 +1000 Subject: [PATCH 4/4] Revert thing --- InvenTree/stock/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index a10262ce9c..7284f8d5cd 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -518,8 +518,8 @@ class StockList(generics.ListCreateAPIView): if serial_number_lte is not None: queryset = queryset.filter(serial__lte=serial_number_lte) - # Filter by "in_stock" status (default behaviour is "True") - in_stock = params.get('in_stock', True) + # Filter by "in_stock" status + in_stock = params.get('in_stock', None) if in_stock is not None: in_stock = str2bool(in_stock)