From a9fffe6a734dfcba897b28023e77f18bba706e95 Mon Sep 17 00:00:00 2001 From: eeintech Date: Wed, 16 Sep 2020 17:02:24 -0500 Subject: [PATCH 1/4] Added latest parts and invalid BOMs on homepage --- InvenTree/part/api.py | 21 +++++++++ .../templates/InvenTree/bom_invalid.html | 15 +++++++ InvenTree/templates/InvenTree/index.html | 44 ++++++++++++++++++- .../templates/InvenTree/latest_parts.html | 15 +++++++ .../templates/InvenTree/starred_parts.html | 2 +- InvenTree/templates/collapse_index.html | 19 ++++++++ 6 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 InvenTree/templates/InvenTree/bom_invalid.html create mode 100644 InvenTree/templates/InvenTree/latest_parts.html create mode 100644 InvenTree/templates/collapse_index.html diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index abc4181895..0afd79af55 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -405,6 +405,27 @@ class PartList(generics.ListCreateAPIView): except (ValueError, Part.DoesNotExist): pass + # Filter by latest part creation date + latest_parts = params.get('latest_parts', None) + + if latest_parts is not None: + # Get the last 5 created parts + queryset = queryset.order_by('-creation_date')[:5] + + # Filter invalid BOMs + bom_invalid = params.get('bom_invalid', None) + + if bom_invalid is not None: + # Get assemblies with invalid BOMs + assemblies = queryset.filter(active=True).filter(assembly=True) + valid_boms = [] + + for part in assemblies: + if part.is_bom_valid: + valid_boms.append(part.pk) + + queryset = assemblies.exclude(pk__in=valid_boms) + # Filter by 'starred' parts? starred = params.get('starred', None) diff --git a/InvenTree/templates/InvenTree/bom_invalid.html b/InvenTree/templates/InvenTree/bom_invalid.html new file mode 100644 index 0000000000..a0cf6ed6d1 --- /dev/null +++ b/InvenTree/templates/InvenTree/bom_invalid.html @@ -0,0 +1,15 @@ +{% extends "collapse_index.html" %} + +{% load i18n %} + +{% block collapse_title %} + +{% trans "BOM - Missing Validation" %}0 +{% endblock %} + +{% block collapse_content %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 570378e55d..e8d46e6f85 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -7,9 +7,24 @@ InvenTree | Index {% block content %}

InvenTree


-{% include "InvenTree/starred_parts.html" with collapse_id="starred" %} -{% include "InvenTree/low_stock.html" with collapse_id="order" %} +
+
+ {% include "InvenTree/latest_parts.html" with collapse_id="latest" %} +
+
+ {% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %} +
+
+ +
+
+ {% include "InvenTree/starred_parts.html" with collapse_id="starred" %} +
+
+ {% include "InvenTree/low_stock.html" with collapse_id="order" %} +
+
{% endblock %} @@ -21,6 +36,18 @@ InvenTree | Index {{ block.super }} +loadPartTable("#latest-parts-table", "{% url 'api-part-list' %}", { + params: { + "latest_parts": true, + } +}); + +loadPartTable("#bom-invalid-table", "{% url 'api-part-list' %}", { + params: { + "bom_invalid": true, + } +}); + loadPartTable("#starred-parts-table", "{% url 'api-part-list' %}", { params: { "starred": true, @@ -33,6 +60,19 @@ loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", { } }); +$("#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; + + $("#latest-parts-count").html(count); +}); + $("#starred-parts-table").on('load-success.bs.table', function() { var count = $("#starred-parts-table").bootstrapTable('getData').length; diff --git a/InvenTree/templates/InvenTree/latest_parts.html b/InvenTree/templates/InvenTree/latest_parts.html new file mode 100644 index 0000000000..e9c9879740 --- /dev/null +++ b/InvenTree/templates/InvenTree/latest_parts.html @@ -0,0 +1,15 @@ +{% extends "collapse_index.html" %} + +{% load i18n %} + +{% block collapse_title %} + +{% trans "Latest Parts" %}0 +{% endblock %} + +{% block collapse_content %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/starred_parts.html b/InvenTree/templates/InvenTree/starred_parts.html index f13987e3c5..f852bf0f83 100644 --- a/InvenTree/templates/InvenTree/starred_parts.html +++ b/InvenTree/templates/InvenTree/starred_parts.html @@ -9,7 +9,7 @@ {% block collapse_content %} - +
{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/collapse_index.html b/InvenTree/templates/collapse_index.html new file mode 100644 index 0000000000..d87f63b244 --- /dev/null +++ b/InvenTree/templates/collapse_index.html @@ -0,0 +1,19 @@ +{% block collapse_preamble %} +{% endblock %} +
+
+
+ + {% block collapse_heading %} + {% endblock %} +
+
+
+ {% block collapse_content %} + {% endblock %} +
+
+
+
\ No newline at end of file From 3d597cc3c3b7769e4367aea479a3220d69f75776 Mon Sep 17 00:00:00 2001 From: eeintech Date: Thu, 17 Sep 2020 14:36:05 -0500 Subject: [PATCH 2/4] Added 'Pending' builds report to homepage, includes builds with 'Allocated' status --- InvenTree/build/api.py | 5 +++- .../templates/InvenTree/bom_invalid.html | 2 +- .../templates/InvenTree/build_pending.html | 15 ++++++++++++ InvenTree/templates/InvenTree/index.html | 24 ++++++++++++++++++- InvenTree/templates/InvenTree/low_stock.html | 2 +- .../templates/InvenTree/starred_parts.html | 2 +- InvenTree/templates/js/build.html | 2 +- 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 InvenTree/templates/InvenTree/build_pending.html diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index 22514ee7b7..592ff5dc16 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -59,7 +59,10 @@ class BuildList(generics.ListCreateAPIView): status = self.request.query_params.get('status', None) if status is not None: - queryset = queryset.filter(status=status) + # Get status codes + codes = status.split('-') + # Filter by codes + queryset = queryset.filter(status__in=codes) # Filter by associated part? part = self.request.query_params.get('part', None) diff --git a/InvenTree/templates/InvenTree/bom_invalid.html b/InvenTree/templates/InvenTree/bom_invalid.html index a0cf6ed6d1..84f4fd7938 100644 --- a/InvenTree/templates/InvenTree/bom_invalid.html +++ b/InvenTree/templates/InvenTree/bom_invalid.html @@ -4,7 +4,7 @@ {% block collapse_title %} -{% trans "BOM - Missing Validation" %}0 +{% trans "BOM Waiting Validation" %}0 {% endblock %} {% block collapse_content %} diff --git a/InvenTree/templates/InvenTree/build_pending.html b/InvenTree/templates/InvenTree/build_pending.html new file mode 100644 index 0000000000..8d8ba7befa --- /dev/null +++ b/InvenTree/templates/InvenTree/build_pending.html @@ -0,0 +1,15 @@ +{% extends "collapse_index.html" %} + +{% load i18n %} + +{% block collapse_title %} + +{% trans "Pending Builds" %}0 +{% endblock %} + +{% block collapse_content %} + + +
+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index e8d46e6f85..b754414efc 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -10,7 +10,7 @@ InvenTree | Index
- {% include "InvenTree/latest_parts.html" with collapse_id="latest" %} + {% include "InvenTree/latest_parts.html" with collapse_id="latest_parts" %}
{% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %} @@ -26,6 +26,14 @@ InvenTree | Index
+
+
+ {% include "InvenTree/build_pending.html" with collapse_id="build_pending" %} +
+
+
+
+ {% endblock %} {% block js_load %} @@ -60,6 +68,14 @@ loadPartTable("#low-stock-table", "{% url 'api-part-list' %}", { } }); +loadBuildTable("#build-pending-table", { + url: "{% url 'api-build-list' %}", + params: { + "part_detail": true, + "status": "10-20", + } +}); + $("#bom-invalid-table").on('load-success.bs.table', function() { var count = $("#bom-invalid-table").bootstrapTable('getData').length; @@ -85,5 +101,11 @@ $("#low-stock-table").on('load-success.bs.table', function() { $("#low-stock-count").html(count); }); +$("#build-pending-table").on('load-success.bs.table', function() { + var count = $("#build-pending-table").bootstrapTable('getData').length; + + $("#build-pending-count").html(count); +}); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/low_stock.html b/InvenTree/templates/InvenTree/low_stock.html index edafab1756..333dbded27 100644 --- a/InvenTree/templates/InvenTree/low_stock.html +++ b/InvenTree/templates/InvenTree/low_stock.html @@ -1,4 +1,4 @@ -{% extends "collapse.html" %} +{% extends "collapse_index.html" %} {% load i18n %} diff --git a/InvenTree/templates/InvenTree/starred_parts.html b/InvenTree/templates/InvenTree/starred_parts.html index f852bf0f83..74f6edafb1 100644 --- a/InvenTree/templates/InvenTree/starred_parts.html +++ b/InvenTree/templates/InvenTree/starred_parts.html @@ -1,4 +1,4 @@ -{% extends "collapse.html" %} +{% extends "collapse_index.html" %} {% load i18n %} diff --git a/InvenTree/templates/js/build.html b/InvenTree/templates/js/build.html index 8682e9bd81..10c017a776 100644 --- a/InvenTree/templates/js/build.html +++ b/InvenTree/templates/js/build.html @@ -13,7 +13,7 @@ function loadBuildTable(table, options) { setupFilterList("build", table); - table.inventreeTable({ + $(table).inventreeTable({ method: 'get', formatNoMatches: function() { return "{% trans "No builds matching query" %}"; From 945c3c214dcf10bb0d5143643dfaea074476ea21 Mon Sep 17 00:00:00 2001 From: eeintech Date: Thu, 17 Sep 2020 17:19:19 -0500 Subject: [PATCH 3/4] Added outstanding purchase and sales orders views to homepage --- .../templates/InvenTree/build_pending.html | 2 +- InvenTree/templates/InvenTree/index.html | 55 ++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/InvenTree/templates/InvenTree/build_pending.html b/InvenTree/templates/InvenTree/build_pending.html index 8d8ba7befa..31a083cfc0 100644 --- a/InvenTree/templates/InvenTree/build_pending.html +++ b/InvenTree/templates/InvenTree/build_pending.html @@ -3,7 +3,7 @@ {% load i18n %} {% block collapse_title %} - + {% trans "Pending Builds" %}0 {% endblock %} diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index b754414efc..c5903d112b 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -12,25 +12,35 @@ InvenTree | Index
{% include "InvenTree/latest_parts.html" with collapse_id="latest_parts" %}
-
- {% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %} -
- - -
{% include "InvenTree/starred_parts.html" with collapse_id="starred" %}
-
- {% include "InvenTree/low_stock.html" with collapse_id="order" %} -
+
+
+ {% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %} +
{% include "InvenTree/build_pending.html" with collapse_id="build_pending" %}
+
+ +
+ {% include "InvenTree/low_stock.html" with collapse_id="order" %} +
+
+
+
+ +
+
+ {% include "InvenTree/po_outstanding.html" with collapse_id="po_outstanding" %} +
+
+ {% include "InvenTree/so_outstanding.html" with collapse_id="so_outstanding" %}
@@ -76,6 +86,22 @@ loadBuildTable("#build-pending-table", { } }); +loadPurchaseOrderTable("#po-outstanding-table", { + url: "{% url 'api-po-list' %}", + params: { + "supplier_detail": true, + "oustanding": true, + } +}); + +loadSalesOrderTable("#so-outstanding-table", { + url: "{% url 'api-so-list' %}", + params: { + "customer_detail": true, + "oustanding": true, + } +}); + $("#bom-invalid-table").on('load-success.bs.table', function() { var count = $("#bom-invalid-table").bootstrapTable('getData').length; @@ -107,5 +133,16 @@ $("#build-pending-table").on('load-success.bs.table', function() { $("#build-pending-count").html(count); }); +$("#po-outstanding-table").on('load-success.bs.table', function() { + var count = $("#po-outstanding-table").bootstrapTable('getData').length; + + $("#po-outstanding-count").html(count); +}); + +$("#so-outstanding-table").on('load-success.bs.table', function() { + var count = $("#so-outstanding-table").bootstrapTable('getData').length; + + $("#so-outstanding-count").html(count); +}); {% endblock %} \ No newline at end of file From c55fa13cdbfb8f0b5e7e50c4ea363baeeb752074 Mon Sep 17 00:00:00 2001 From: eeintech Date: Fri, 18 Sep 2020 11:40:50 -0500 Subject: [PATCH 4/4] Added part list which require more stock to be built --- InvenTree/part/api.py | 16 +++++++ InvenTree/templates/InvenTree/index.html | 44 ++++++++++++------- .../templates/InvenTree/po_outstanding.html | 15 +++++++ .../InvenTree/required_stock_build.html | 15 +++++++ .../templates/InvenTree/so_outstanding.html | 15 +++++++ 5 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 InvenTree/templates/InvenTree/po_outstanding.html create mode 100644 InvenTree/templates/InvenTree/required_stock_build.html create mode 100644 InvenTree/templates/InvenTree/so_outstanding.html 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