From 597ab37ba6dae8cd4f598dc6c10028ebd0eb4158 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 19 Sep 2020 21:18:29 +1000 Subject: [PATCH] Further cleanup --- InvenTree/part/api.py | 7 +++++++ InvenTree/templates/InvenTree/index.html | 17 +++++++++-------- InvenTree/templates/js/build.html | 6 +++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 79cb557450..9d9d56d253 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -408,6 +408,10 @@ class PartList(generics.ListCreateAPIView): # Filter by whether the BOM has been validated (or not) bom_valid = params.get('bom_valid', None) + # TODO: Querying bom_valid status may be quite expensive + # TODO: (It needs to be profiled!) + # TODO: It might be worth caching the bom_valid status to a database column + if bom_valid is not None: bom_valid = str2bool(bom_valid) @@ -499,6 +503,9 @@ class PartList(generics.ListCreateAPIView): # Filter by "parts which need stock to complete build" stock_to_build = params.get('stock_to_build', None) + # TODO: This is super expensive, database query wise... + # TODO: Need to figure out a cheaper way of making this filter query + if stock_to_build is not None: # Filter only active parts queryset = queryset.filter(active=True) diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 71c95045b4..df2ae1414a 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -82,19 +82,20 @@ loadBuildTable("#build-pending-table", { params: { part_detail: true, active: true, - } + }, + disableFilters: true, }); loadSimplePartTable("#low-stock-table", "{% url 'api-part-list' %}", { params: { - "low_stock": true, + low_stock: true, }, name: "low_stock_parts", }); loadSimplePartTable("#stock-to-build-table", "{% url 'api-part-list' %}", { params: { - "stock_to_build": true, + stock_to_build: true, }, name: "to_build_parts", }); @@ -102,17 +103,17 @@ loadSimplePartTable("#stock-to-build-table", "{% url 'api-part-list' %}", { loadPurchaseOrderTable("#po-outstanding-table", { url: "{% url 'api-po-list' %}", params: { - "supplier_detail": true, - "outstanding": true, + supplier_detail: true, + outstanding: true, } }); loadSalesOrderTable("#so-outstanding-table", { url: "{% url 'api-so-list' %}", params: { - "customer_detail": true, - "outstanding": true, - } + customer_detail: true, + outstanding: true, + }, }); $("#latest-parts-table").on('load-success.bs.table', function() { diff --git a/InvenTree/templates/js/build.html b/InvenTree/templates/js/build.html index 10c017a776..e36e15ddeb 100644 --- a/InvenTree/templates/js/build.html +++ b/InvenTree/templates/js/build.html @@ -5,7 +5,11 @@ function loadBuildTable(table, options) { var params = options.params || {}; - var filters = loadTableFilters("build"); + var filters = {}; + + if (!options.disableFilters) { + loadTableFilters("build"); + } for (var key in params) { filters[key] = params[key];