From 868697392f75748921c1385fa3419efbe099136c Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 19 Aug 2022 08:39:54 +1000 Subject: [PATCH] Include variant stock in part table (#3573) --- InvenTree/templates/js/translated/part.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index 5a3799e0b2..7171e6c7f9 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -1463,18 +1463,24 @@ function loadPartTable(table, url, options={}) { var text = ''; + var total_stock = row.in_stock; + + if (row.variant_stock) { + total_stock += row.variant_stock; + } + if (row.unallocated_stock != row.in_stock) { - text = `${row.unallocated_stock} / ${row.in_stock}`; + text = `${row.unallocated_stock} / ${total_stock}`; } else { - text = `${row.in_stock}`; + text = `${total_stock}`; } // Construct extra informational badges var badges = ''; - if (row.in_stock == 0) { + if (total_stock == 0) { badges += ``; - } else if (row.in_stock < row.minimum_stock) { + } else if (total_stock < row.minimum_stock) { badges += ``; } @@ -1492,6 +1498,10 @@ function loadPartTable(table, url, options={}) { ); } + if (row.variant_stock && row.variant_stock > 0) { + badges += ``; + } + text = renderLink(text, `/part/${row.pk}/?display=part-stock`); text += badges;