mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1093 from SchrodingersGat/bom-filters
Add filtering for BOM table
This commit is contained in:
commit
fb28204dfd
@ -782,6 +782,24 @@ class BomList(generics.ListCreateAPIView):
|
|||||||
sub_part_trackable = str2bool(sub_part_trackable)
|
sub_part_trackable = str2bool(sub_part_trackable)
|
||||||
queryset = queryset.filter(sub_part__trackable=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
|
return queryset
|
||||||
|
|
||||||
filter_backends = [
|
filter_backends = [
|
||||||
|
@ -103,6 +103,29 @@ function loadBomTable(table, options) {
|
|||||||
* BOM data are retrieved from the server via AJAX query
|
* 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
|
// Construct the table columns
|
||||||
|
|
||||||
var cols = [];
|
var cols = [];
|
||||||
@ -286,19 +309,6 @@ function loadBomTable(table, options) {
|
|||||||
|
|
||||||
// Configure the table (bootstrap-table)
|
// 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
|
// Function to request BOM data for sub-items
|
||||||
// This function may be called recursively for multi-level BOMs
|
// This function may be called recursively for multi-level BOMs
|
||||||
function requestSubItems(bom_pk, part_pk) {
|
function requestSubItems(bom_pk, part_pk) {
|
||||||
@ -349,9 +359,10 @@ function loadBomTable(table, options) {
|
|||||||
return {classes: 'rowinvalid'};
|
return {classes: 'rowinvalid'};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatNoMatches: function() { return "{% trans "No BOM items found" %}"; },
|
formatNoMatches: function() { return '{% trans "No BOM items found" %}'; },
|
||||||
clickToSelect: true,
|
clickToSelect: true,
|
||||||
queryParams: params,
|
queryParams: filters,
|
||||||
|
original: params,
|
||||||
columns: cols,
|
columns: cols,
|
||||||
url: options.bom_url,
|
url: options.bom_url,
|
||||||
onPostBody: function() {
|
onPostBody: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user