2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

Include variant stock in part table (#3573)

This commit is contained in:
Oliver 2022-08-19 08:39:54 +10:00 committed by GitHub
parent efafa3960b
commit 868697392f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1463,18 +1463,24 @@ function loadPartTable(table, url, options={}) {
var text = ''; var text = '';
var total_stock = row.in_stock;
if (row.variant_stock) {
total_stock += row.variant_stock;
}
if (row.unallocated_stock != row.in_stock) { if (row.unallocated_stock != row.in_stock) {
text = `${row.unallocated_stock} / ${row.in_stock}`; text = `${row.unallocated_stock} / ${total_stock}`;
} else { } else {
text = `${row.in_stock}`; text = `${total_stock}`;
} }
// Construct extra informational badges // Construct extra informational badges
var badges = ''; var badges = '';
if (row.in_stock == 0) { if (total_stock == 0) {
badges += `<span class='fas fa-exclamation-circle icon-red float-right' title='{% trans "No stock" %}'></span>`; badges += `<span class='fas fa-exclamation-circle icon-red float-right' title='{% trans "No stock" %}'></span>`;
} else if (row.in_stock < row.minimum_stock) { } else if (total_stock < row.minimum_stock) {
badges += `<span class='fas fa-exclamation-circle icon-yellow float-right' title='{% trans "Low stock" %}'></span>`; badges += `<span class='fas fa-exclamation-circle icon-yellow float-right' title='{% trans "Low stock" %}'></span>`;
} }
@ -1492,6 +1498,10 @@ function loadPartTable(table, url, options={}) {
); );
} }
if (row.variant_stock && row.variant_stock > 0) {
badges += `<span class='fas fa-info-circle float-right' title='{% trans "Includes variant stock" %}'></span>`;
}
text = renderLink(text, `/part/${row.pk}/?display=part-stock`); text = renderLink(text, `/part/${row.pk}/?display=part-stock`);
text += badges; text += badges;