From 910d9a15f6e3ce1554cdc68bab92e32824b37249 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 10:39:48 +1000 Subject: [PATCH 1/3] Display batch information in stock table --- .../static/script/inventree/stock.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 189f1249eb..8d1c1539e3 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -82,6 +82,32 @@ function loadStockTable(table, options) { }); return stock; + } else if (field == 'batch') { + var batches = []; + + data.forEach(function(item) { + var batch = item.batch; + + if (!batch) { + batch = '-'; + } + + if (!batches.includes(item.batch)) { + batches.push(item.batch); + } + }); + + if (batches.length > 1) { + return "" + batches.length + " batches"; + } else if (batches.length == 1) { + if (batches[0]) { + return batches[0]; + } else { + return '-'; + } + } else { + return '-'; + } } else if (field == 'location__path') { /* Determine how many locations */ var locations = []; @@ -165,6 +191,11 @@ function loadStockTable(table, options) { return text; } }, + { + field: 'batch', + title: 'Batch', + sortable: true, + }, { field: 'location__path', title: 'Location', From 8703ee90c6bdd800bcc2009e8e38aa35e0dbc82b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 10:41:22 +1000 Subject: [PATCH 2/3] Improve grouping --- InvenTree/InvenTree/static/script/inventree/stock.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 8d1c1539e3..e4fa188598 100644 --- a/InvenTree/InvenTree/static/script/inventree/stock.js +++ b/InvenTree/InvenTree/static/script/inventree/stock.js @@ -88,12 +88,12 @@ function loadStockTable(table, options) { data.forEach(function(item) { var batch = item.batch; - if (!batch) { + if (!batch || batch == '') { batch = '-'; } - if (!batches.includes(item.batch)) { - batches.push(item.batch); + if (!batches.includes(batch)) { + batches.push(batch); } }); From 9c864aa619f1cf0301e7f0e0c77ec975362401c0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Sep 2019 10:51:39 +1000 Subject: [PATCH 3/3] Hide the 'sellable' tag for now - Keep hidden until parts can actually be sold --- InvenTree/part/templates/part/detail.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 294125842e..d8bb40d792 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -130,6 +130,7 @@ Part can be purchased from external suppliers {% endif %} + {% if 0 %} Sellable {% include "slide.html" with state=part.salable field='salable' %} @@ -139,6 +140,7 @@ Part cannot be sold to customers {% endif %} + {% endif %}