From 54cb8fa7364a55840daf2dbd1adb3ae0313f3989 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 3 Jul 2021 00:08:00 +0200 Subject: [PATCH 1/2] adds depleted stock to index --- InvenTree/part/api.py | 9 +++++++++ InvenTree/templates/InvenTree/index.html | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 60cea121a7..b84ef27af1 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -651,6 +651,15 @@ class PartList(generics.ListCreateAPIView): # Filter items which have an 'in_stock' level higher than 'minimum_stock' queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock'))) + # If we are filtering by 'depleted_stock' status + depleted_stock = params.get('depleted_stock', None) + + if depleted_stock is not None: + depleted_stock = str2bool(depleted_stock) + + if depleted_stock: + queryset = queryset.filter(Q(in_stock=0) & ~Q(stock_item_count=0)) + # Filter by "parts which need stock to complete build" stock_to_build = params.get('stock_to_build', None) diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 434d652728..a3d793dd26 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -128,6 +128,7 @@ loadSimplePartTable("#table-bom-validation", "{% url 'api-part-list' %}", { addHeaderTitle('{% trans "Stock" %}'); addHeaderAction('recently-updated-stock', '{% trans "Recently Updated" %}', 'fa-clock'); addHeaderAction('low-stock', '{% trans "Low Stock" %}', 'fa-shopping-cart'); +addHeaderAction('depleted-stock', '{% trans "Depleted Stock" %}', 'fa-times'); addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa-bullhorn'); loadStockTable($('#table-recently-updated-stock'), { @@ -170,6 +171,13 @@ loadSimplePartTable("#table-low-stock", "{% url 'api-part-list' %}", { name: "low_stock_parts", }); +loadSimplePartTable("#table-depleted-stock", "{% url 'api-part-list' %}", { + params: { + depleted_stock: true, + }, + name: "depleted_stock_parts", +}); + loadSimplePartTable("#table-stock-to-build", "{% url 'api-part-list' %}", { params: { stock_to_build: true, From 23bd6acc947b531e72a2684de7f75087b7f9a307 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 3 Jul 2021 00:18:41 +0200 Subject: [PATCH 2/2] changed doc string --- InvenTree/part/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index b84ef27af1..8415e56ba9 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -651,7 +651,7 @@ class PartList(generics.ListCreateAPIView): # Filter items which have an 'in_stock' level higher than 'minimum_stock' queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock'))) - # If we are filtering by 'depleted_stock' status + # Filer by 'depleted_stock' status -> has no stock and stock items depleted_stock = params.get('depleted_stock', None) if depleted_stock is not None: