Display packaging info in stock table

This commit is contained in:
Oliver Walters 2021-02-19 11:09:24 +11:00
parent 556d6455e8
commit 644583f636
2 changed files with 31 additions and 1 deletions

View File

@ -198,6 +198,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
'location',
'location_detail',
'notes',
'packaging',
'part',
'part_detail',
'pk',

View File

@ -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" %}',