diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index b8e71ff58c..9cb2538ba7 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -198,6 +198,7 @@ class StockItemSerializer(InvenTreeModelSerializer): 'location', 'location_detail', 'notes', + 'packaging', 'part', 'part_detail', 'pk', diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index 3e6fee43e4..4ffcc2aee4 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -359,6 +359,29 @@ function loadStockTable(table, options) { else if (field == 'part_detail.description') { return row.part_detail.description; } + else if (field == 'packaging') { + var packaging = []; + + data.forEach(function(item) { + var pkg = String(item.packaging); + + if (!pkg || pkg == '') { + pkg = '-'; + } + + if (!packaging.includes(pkg)) { + packaging.push(pkg); + } + }); + + if (packaging.length > 1) { + return "..."; + } else if (packaging.length == 1) { + return packaging[0]; + } else { + return "-"; + } + } else if (field == 'quantity') { var stock = 0; var items = 0; @@ -388,7 +411,7 @@ function loadStockTable(table, options) { // Multiple status codes if (statii.length > 1) { - return "-"; + return "..."; } else if (statii.length == 1) { return stockStatusDisplay(statii[0]); } else { @@ -619,6 +642,12 @@ function loadStockTable(table, options) { title: '{% trans "Last Updated" %}', sortable: true, }, + { + field: 'packaging', + title: '{% trans "Packaging" %}', + sortable: true, + searchable: true, + }, { field: 'notes', title: '{% trans "Notes" %}',