2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-06 07:18:48 +00:00

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',
'location_detail', 'location_detail',
'notes', 'notes',
'packaging',
'part', 'part',
'part_detail', 'part_detail',
'pk', 'pk',

View File

@ -359,6 +359,29 @@ function loadStockTable(table, options) {
else if (field == 'part_detail.description') { else if (field == 'part_detail.description') {
return row.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') { else if (field == 'quantity') {
var stock = 0; var stock = 0;
var items = 0; var items = 0;
@ -388,7 +411,7 @@ function loadStockTable(table, options) {
// Multiple status codes // Multiple status codes
if (statii.length > 1) { if (statii.length > 1) {
return "-"; return "...";
} else if (statii.length == 1) { } else if (statii.length == 1) {
return stockStatusDisplay(statii[0]); return stockStatusDisplay(statii[0]);
} else { } else {
@ -619,6 +642,12 @@ function loadStockTable(table, options) {
title: '{% trans "Last Updated" %}', title: '{% trans "Last Updated" %}',
sortable: true, sortable: true,
}, },
{
field: 'packaging',
title: '{% trans "Packaging" %}',
sortable: true,
searchable: true,
},
{ {
field: 'notes', field: 'notes',
title: '{% trans "Notes" %}', title: '{% trans "Notes" %}',