From dae45875fbd1352b50c6d78cde313196ea6a4493 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 26 Mar 2020 14:46:23 +1100 Subject: [PATCH 1/2] Add 'on_order' quantity to the part list API --- InvenTree/part/api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index a121553409..d24f0dc6ee 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -172,6 +172,7 @@ class PartList(generics.ListCreateAPIView): 'active', ).annotate( in_stock=Sum('stock_items__quantity'), + on_order=Sum('supplier_parts__purchase_order_line_items__quantity'), ) # TODO - Annotate total being built From 99efbd4c40fb59432118bbb732d287b56814809d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 26 Mar 2020 14:46:40 +1100 Subject: [PATCH 2/2] If a part has no stock but is on order, display an "on-order" badge --- .../InvenTree/static/script/inventree/part.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index 8ad934760b..c94c512d6f 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -182,17 +182,27 @@ function loadPartTable(table, url, options={}) { searchable: false, sortable: true, formatter: function(value, row, index, field) { + console.log("On order:", row.on_order); + + var html = ""; + var link = "stock"; + if (value) { if (row.units) { value += ' ' + row.units + ''; } - return renderLink(value, '/part/' + row.pk + '/stock/'); - } - else { - return "No Stock"; + html = value; + + } else if (row.on_order) { + value = "On Order : " + row.on_order + ""; + link = "orders"; + } else { + value ="No Stock"; } + + return renderLink(value, '/part/' + row.pk + "/" + link + "/"); } });