diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 0afd79af55..cf260d7bfa 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -498,6 +498,22 @@ 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'))) + # Filter by "parts which need stock to complete build" + stock_to_build = params.get('stock_to_build', None) + + if stock_to_build is not None: + # Filter only active parts + queryset = queryset.filter(active=True) + parts_need_stock = [] + + # Find parts with active builds + # where any subpart's stock is lower than quantity being built + for part in queryset: + if part.active_builds and part.can_build < part.quantity_being_built: + parts_need_stock.append(part.pk) + + queryset = queryset.filter(pk__in=parts_need_stock) + return queryset permission_classes = [ diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index c5903d112b..fa9818069e 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -32,6 +32,7 @@ InvenTree | Index {% include "InvenTree/low_stock.html" with collapse_id="order" %}
+ {% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
@@ -60,15 +61,23 @@ loadPartTable("#latest-parts-table", "{% url 'api-part-list' %}", { } }); +loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", { + params: { + "starred": true, + } +}); + loadPartTable("#bom-invalid-table", "{% url 'api-part-list' %}", { params: { "bom_invalid": true, } }); -loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", { +loadBuildTable("#build-pending-table", { + url: "{% url 'api-build-list' %}", params: { - "starred": true, + "part_detail": true, + "status": "10-20", } }); @@ -78,11 +87,9 @@ loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", { } }); -loadBuildTable("#build-pending-table", { - url: "{% url 'api-build-list' %}", +loadPartTable("#stock-to-build-table", "{% url 'api-part-list' %}", { params: { - "part_detail": true, - "status": "10-20", + "stock_to_build": true, } }); @@ -102,13 +109,6 @@ loadSalesOrderTable("#so-outstanding-table", { } }); -$("#bom-invalid-table").on('load-success.bs.table', function() { - var count = $("#bom-invalid-table").bootstrapTable('getData').length; - - $("#bom-invalid-count").html(count); -}); - - $("#latest-parts-table").on('load-success.bs.table', function() { var count = $("#latest-parts-table").bootstrapTable('getData').length; @@ -121,10 +121,10 @@ $("#starred-parts-table").on('load-success.bs.table', function() { $("#starred-parts-count").html(count); }); -$("#low-stock-table").on('load-success.bs.table', function() { - var count = $("#low-stock-table").bootstrapTable('getData').length; +$("#bom-invalid-table").on('load-success.bs.table', function() { + var count = $("#bom-invalid-table").bootstrapTable('getData').length; - $("#low-stock-count").html(count); + $("#bom-invalid-count").html(count); }); $("#build-pending-table").on('load-success.bs.table', function() { @@ -133,6 +133,18 @@ $("#build-pending-table").on('load-success.bs.table', function() { $("#build-pending-count").html(count); }); +$("#low-stock-table").on('load-success.bs.table', function() { + var count = $("#low-stock-table").bootstrapTable('getData').length; + + $("#low-stock-count").html(count); +}); + +$("#stock-to-build-table").on('load-success.bs.table', function() { + var count = $("#stock-to-build-table").bootstrapTable('getData').length; + + $("#stock-to-build-count").html(count); +}); + $("#po-outstanding-table").on('load-success.bs.table', function() { var count = $("#po-outstanding-table").bootstrapTable('getData').length; diff --git a/InvenTree/templates/InvenTree/po_outstanding.html b/InvenTree/templates/InvenTree/po_outstanding.html new file mode 100644 index 0000000000..063915a414 --- /dev/null +++ b/InvenTree/templates/InvenTree/po_outstanding.html @@ -0,0 +1,15 @@ +{% extends "collapse_index.html" %} + +{% load i18n %} + +{% block collapse_title %} + +{% trans "Outstanding Purchase Orders" %}0 +{% endblock %} + +{% block collapse_content %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/required_stock_build.html b/InvenTree/templates/InvenTree/required_stock_build.html new file mode 100644 index 0000000000..8202766ec1 --- /dev/null +++ b/InvenTree/templates/InvenTree/required_stock_build.html @@ -0,0 +1,15 @@ +{% extends "collapse_index.html" %} + +{% load i18n %} + +{% block collapse_title %} + +{% trans "Require Stock To Complete Build" %}0 +{% endblock %} + +{% block collapse_content %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/so_outstanding.html b/InvenTree/templates/InvenTree/so_outstanding.html new file mode 100644 index 0000000000..023abb2b6a --- /dev/null +++ b/InvenTree/templates/InvenTree/so_outstanding.html @@ -0,0 +1,15 @@ +{% extends "collapse_index.html" %} + +{% load i18n %} + +{% block collapse_title %} + +{% trans "Outstanding Sales Orders" %}0 +{% endblock %} + +{% block collapse_content %} + + +
+ +{% endblock %} \ No newline at end of file