diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 975a8af31d..496153a6d0 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -782,6 +782,24 @@ class BomList(generics.ListCreateAPIView): sub_part_trackable = str2bool(sub_part_trackable) queryset = queryset.filter(sub_part__trackable=sub_part_trackable) + # Filter by whether the BOM line has been validated + validated = params.get('validated', None) + + if validated is not None: + validated = str2bool(validated) + + # Work out which lines have actually been validated + pks = [] + + for bom_item in queryset.all(): + if bom_item.is_line_valid: + pks.append(bom_item.pk) + + if validated: + queryset = queryset.filter(pk__in=pks) + else: + queryset = queryset.exclude(pk__in=pks) + return queryset filter_backends = [ diff --git a/InvenTree/templates/js/bom.js b/InvenTree/templates/js/bom.js index d1d7d91346..c8da09da43 100644 --- a/InvenTree/templates/js/bom.js +++ b/InvenTree/templates/js/bom.js @@ -103,6 +103,29 @@ function loadBomTable(table, options) { * BOM data are retrieved from the server via AJAX query */ + var params = { + part: options.parent_id, + ordering: 'name', + } + + if (options.part_detail) { + params.part_detail = true; + } + + params.sub_part_detail = true; + + var filters = {}; + + if (!options.disableFilters) { + filters = loadTableFilters('bom'); + } + + for (var key in params) { + filters[key] = params[key]; + } + + setupFilterList('bom', $(table)); + // Construct the table columns var cols = []; @@ -286,19 +309,6 @@ function loadBomTable(table, options) { // Configure the table (bootstrap-table) - var params = { - part: options.parent_id, - ordering: 'name', - } - - if (options.part_detail) { - params.part_detail = true; - } - - if (options.sub_part_detail) { - params.sub_part_detail = true; - } - // Function to request BOM data for sub-items // This function may be called recursively for multi-level BOMs function requestSubItems(bom_pk, part_pk) { @@ -349,9 +359,10 @@ function loadBomTable(table, options) { return {classes: 'rowinvalid'}; } }, - formatNoMatches: function() { return "{% trans "No BOM items found" %}"; }, + formatNoMatches: function() { return '{% trans "No BOM items found" %}'; }, clickToSelect: true, - queryParams: params, + queryParams: filters, + original: params, columns: cols, url: options.bom_url, onPostBody: function() {