From e8e0ab8416968c8b4e4a17e72b843a5413d47185 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 30 Mar 2020 13:21:33 +1100 Subject: [PATCH 1/4] Include 'minimum_stock' information in part list api --- InvenTree/part/api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 1d6aaa84aa..2a96a47fef 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -178,6 +178,7 @@ class PartList(generics.ListCreateAPIView): 'is_template', 'URL', 'units', + 'minimum_stock', 'trackable', 'assembly', 'component', From 06f28898a0e3348c92d01f247049a2fbacb8c710 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 30 Mar 2020 13:31:14 +1100 Subject: [PATCH 2/4] separate display for "no stock" and "low stock" in list view --- InvenTree/InvenTree/static/script/inventree/part.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index 693a4d1faa..ac2cbdd2e5 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -184,23 +184,28 @@ function loadPartTable(table, url, options={}) { formatter: function(value, row, index, field) { var html = ""; var link = "stock"; - + if (value) { + // There IS stock available for this part - if (row.units) { - value += ' ' + row.units + ''; + // Is stock "low" (below the 'minimum_stock' quantity)? + if (row.minimum_stock && row.minimum_stock > value) { + value = "Low stock : " + row.in_stock + ""; } html = value; } else if (row.on_order) { + // There is no stock available, but stock is on order value = "On Order : " + row.on_order + ""; link = "orders"; } else if (row.building) { + // There is no stock available, but stock is being built value = "Building : " + row.building + ""; link = "builds"; } else { - value ="No Stock"; + // There is no stock available + value ="No Stock"; } return renderLink(value, '/part/' + row.pk + "/" + link + "/"); From 5aec3df7c9d207e3102f8e38d05c0706e13720b0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 30 Mar 2020 13:37:34 +1100 Subject: [PATCH 3/4] Add stock-info labels to Part info page --- InvenTree/part/templates/part/part_base.html | 2 +- InvenTree/part/templates/part/stock_count.html | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 InvenTree/part/templates/part/stock_count.html diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 27e5aedb83..7eb2f1dc5a 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -98,7 +98,7 @@ {% trans "In Stock" %} - {% decimal part.total_stock %} + {% include "part/stock_count.html" %} {% if not part.is_template %} {% if part.allocation_count > 0 %} diff --git a/InvenTree/part/templates/part/stock_count.html b/InvenTree/part/templates/part/stock_count.html new file mode 100644 index 0000000000..07b3ac9c9b --- /dev/null +++ b/InvenTree/part/templates/part/stock_count.html @@ -0,0 +1,10 @@ +{% load inventree_extras %} +{% load i18n %} + +{% decimal part.total_stock %} + +{% if part.total_stock == 0 %} +{% trans "No Stock" %} +{% elif part.total_stock < part.minimum_stock %} +{% trans "Low Stock" %} +{% endif %} \ No newline at end of file From 0dc6d9d37e7e9dc706b2cca7d2be8d624a3c1dec Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 30 Mar 2020 15:04:56 +1100 Subject: [PATCH 4/4] Improved visual layout --- InvenTree/InvenTree/static/css/inventree.css | 4 ++++ InvenTree/InvenTree/static/script/inventree/part.js | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 3725d79c7b..b4943a9b9a 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -112,6 +112,10 @@ font-size: 100%; } +.label-right { + float: right; +} + /* Bootstrap table overrides */ .stock-sub-group td { diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index ac2cbdd2e5..f05c5670da 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -182,7 +182,6 @@ function loadPartTable(table, url, options={}) { searchable: false, sortable: true, formatter: function(value, row, index, field) { - var html = ""; var link = "stock"; if (value) { @@ -190,22 +189,20 @@ function loadPartTable(table, url, options={}) { // Is stock "low" (below the 'minimum_stock' quantity)? if (row.minimum_stock && row.minimum_stock > value) { - value = "Low stock : " + row.in_stock + ""; + value += "Low stock"; } - html = value; - } else if (row.on_order) { // There is no stock available, but stock is on order - value = "On Order : " + row.on_order + ""; + value = "0On Order : " + row.on_order + ""; link = "orders"; } else if (row.building) { // There is no stock available, but stock is being built - value = "Building : " + row.building + ""; + value = "0Building : " + row.building + ""; link = "builds"; } else { // There is no stock available - value ="No Stock"; + value = "0No Stock"; } return renderLink(value, '/part/' + row.pk + "/" + link + "/");