From 06f28898a0e3348c92d01f247049a2fbacb8c710 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 30 Mar 2020 13:31:14 +1100 Subject: [PATCH] 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 + "/");