From 930f903f5d8c4139d2f151d6a51c425430a79537 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 22 Jun 2020 10:48:41 +1000 Subject: [PATCH] Add ability to display "out of stock" items against a part --- InvenTree/InvenTree/static/script/inventree/filters.js | 2 +- InvenTree/part/templates/part/stock.html | 1 - InvenTree/part/templates/part/tabs.html | 9 --------- InvenTree/stock/serializers.py | 2 ++ InvenTree/stock/templates/stock/location.html | 1 - InvenTree/templates/js/stock.html | 9 +++++++-- InvenTree/templates/js/table_filters.html | 5 +++++ 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/filters.js b/InvenTree/InvenTree/static/script/inventree/filters.js index 3209ba3beb..df767441d4 100644 --- a/InvenTree/InvenTree/static/script/inventree/filters.js +++ b/InvenTree/InvenTree/static/script/inventree/filters.js @@ -14,7 +14,7 @@ function defaultFilters() { return { - stock: "cascade=1", + stock: "cascade=1&in_stock=1", build: "", parts: "cascade=1", company: "", diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index 03174f45c3..3030363476 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -40,7 +40,6 @@ part: {{ part.id }}, location_detail: true, part_detail: true, - in_stock: true, }, groupByField: 'location', buttons: [ diff --git a/InvenTree/part/templates/part/tabs.html b/InvenTree/part/templates/part/tabs.html index 82d727eeb3..ffb92cf191 100644 --- a/InvenTree/part/templates/part/tabs.html +++ b/InvenTree/part/templates/part/tabs.html @@ -51,15 +51,6 @@ {% endif %} {% if part.trackable %} - {% if 0 %} - - - {% trans "Tracking" %} - {% if parts.serials.all|length > 0 %} - {{ part.serials.all|length }} - {% endif %} - - {% endif %} {% trans "Tests" %} {% if part.getTestTemplates.count > 0 %}{{ part.getTestTemplates.count }}{% endif %} diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index bde9b2b25b..07fdd7952e 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -71,6 +71,7 @@ class StockItemSerializer(InvenTreeModelSerializer): 'belongs_to', 'build', 'build_order', + 'customer', 'sales_order', 'supplier_part', 'supplier_part__supplier', @@ -141,6 +142,7 @@ class StockItemSerializer(InvenTreeModelSerializer): 'batch', 'build_order', 'belongs_to', + 'customer', 'in_stock', 'link', 'location', diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 20032e557c..7e6a4fab42 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -248,7 +248,6 @@ {% endif %} part_detail: true, location_detail: true, - in_stock: true, }, url: "{% url 'api-stock-list' %}", }); diff --git a/InvenTree/templates/js/stock.html b/InvenTree/templates/js/stock.html index 789667b006..2600a1635d 100644 --- a/InvenTree/templates/js/stock.html +++ b/InvenTree/templates/js/stock.html @@ -494,10 +494,15 @@ function loadStockTable(table, options) { sortable: true, formatter: function(value, row, index, field) { if (value) { - return renderLink(value, '/stock/location/' + row.location + '/'); + return renderLink(value, `/stock/location/${row.location}/`); } else { - return '{% trans "No stock location set" %}'; + if (row.customer) { + var text = "{% trans "Shipped to customer" %}"; + return renderLink(text, `/company/${row.customer}/assigned-stock/`); + } else { + return '{% trans "No stock location set" %}'; + } } } }, diff --git a/InvenTree/templates/js/table_filters.html b/InvenTree/templates/js/table_filters.html index bec29b0487..3c9381331c 100644 --- a/InvenTree/templates/js/table_filters.html +++ b/InvenTree/templates/js/table_filters.html @@ -14,6 +14,11 @@ function getAvailableTableFilters(tableKey) { // Filters for the "Stock" table if (tableKey == 'stock') { return { + in_stock: { + type: 'bool', + title: '{% trans "In Stock" %}', + description: '{% trans "Show items which are in stock" %}', + }, cascade: { type: 'bool', title: '{% trans "Include sublocations" %}',