diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js index 189f1249eb..e4fa188598 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 == '') { + batch = '-'; + } + + if (!batches.includes(batch)) { + batches.push(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', 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 @@