From 979f543c3f332ef443aaebe8ef8a65440c6fbfc8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 3 Mar 2021 08:44:13 +1100 Subject: [PATCH] Add build orders to search results list --- InvenTree/build/api.py | 2 +- .../build/templates/build/build_children.html | 1 - InvenTree/build/templates/build/index.html | 3 --- InvenTree/order/templates/order/so_builds.html | 1 - InvenTree/part/templates/part/build.html | 1 - InvenTree/templates/InvenTree/index.html | 2 -- InvenTree/templates/InvenTree/search.html | 14 ++++++++++++++ InvenTree/templates/js/build.js | 4 ++++ 8 files changed, 19 insertions(+), 9 deletions(-) diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index 175f39ba63..e6331f2b6a 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -51,7 +51,7 @@ class BuildList(generics.ListCreateAPIView): search_fields = [ 'reference', 'part__name', - 'description', + 'title', ] def get_queryset(self): diff --git a/InvenTree/build/templates/build/build_children.html b/InvenTree/build/templates/build/build_children.html index 034bc6d98f..3bab257d81 100644 --- a/InvenTree/build/templates/build/build_children.html +++ b/InvenTree/build/templates/build/build_children.html @@ -33,7 +33,6 @@ loadBuildTable($('#sub-build-table'), { url: '{% url "api-build-list" %}', filterTarget: "#filter-list-sub-build", params: { - part_detail: true, ancestor: {{ build.pk }}, } }); diff --git a/InvenTree/build/templates/build/index.html b/InvenTree/build/templates/build/index.html index 05864cd780..75dc497b4b 100644 --- a/InvenTree/build/templates/build/index.html +++ b/InvenTree/build/templates/build/index.html @@ -179,9 +179,6 @@ $("#new-build").click(function() { loadBuildTable($("#build-table"), { url: "{% url 'api-build-list' %}", - params: { - part_detail: "true", - }, }); $('#multi-build-print').click(function() { diff --git a/InvenTree/order/templates/order/so_builds.html b/InvenTree/order/templates/order/so_builds.html index 91461136a0..e29a76b64d 100644 --- a/InvenTree/order/templates/order/so_builds.html +++ b/InvenTree/order/templates/order/so_builds.html @@ -27,7 +27,6 @@ loadBuildTable($("#builds-table"), { url: "{% url 'api-build-list' %}", params: { sales_order: {{ order.id }}, - part_detail: true, }, }); diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html index 0e7b5d4d8f..4f0bd3a0c6 100644 --- a/InvenTree/part/templates/part/build.html +++ b/InvenTree/part/templates/part/build.html @@ -43,7 +43,6 @@ loadBuildTable($("#build-table"), { url: "{% url 'api-build-list' %}", params: { - part_detail: "true", part: {{ part.id }}, } }); diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 2023227bce..b7807840c5 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -185,7 +185,6 @@ addHeaderAction('build-overdue', '{% trans "Overdue Build Orders" %}', 'fa-calen loadBuildTable("#table-build-pending", { url: "{% url 'api-build-list' %}", params: { - part_detail: true, active: true, }, disableFilters: true, @@ -194,7 +193,6 @@ loadBuildTable("#table-build-pending", { loadBuildTable("#table-build-overdue", { url: "{% url 'api-build-list' %}", params: { - part_detail: true, overdue: true, }, disableFilters: true, diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index 355865d3ee..5eb755dcb2 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -162,6 +162,20 @@ InvenTree | {% trans "Search Results" %} {% endif %} + {% if roles.build.view %} + + addItemTitle('{% trans "Build" %}'); + + addItem('build-order', '{% trans "Build Orders" %}', 'fa-tools'); + + loadBuildTable('#table-build-order', { + params: { + search: '{{ query }}', + } + }); + + {% endif %} + {% if roles.stock.view %} addItemTitle('{% trans "Stock" %}'); diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index daa78748a4..539d1565aa 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -609,6 +609,8 @@ function loadBuildTable(table, options) { var params = options.params || {}; var filters = {}; + + params['part_detail'] = true; if (!options.disableFilters) { filters = loadTableFilters("build"); @@ -618,6 +620,8 @@ function loadBuildTable(table, options) { filters[key] = params[key]; } + options.url = options.url || '{% url "api-build-list" %}'; + var filterTarget = options.filterTarget || null; setupFilterList("build", table, filterTarget);