mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add ability to filter BOM status by "validated" field
This commit is contained in:
parent
24ab48ef4c
commit
8f108d42d2
@ -768,6 +768,25 @@ class BomList(generics.ListCreateAPIView):
|
|||||||
trackable = str2bool(trackable)
|
trackable = str2bool(trackable)
|
||||||
queryset = queryset.filter(sub_part__trackable=trackable)
|
queryset = queryset.filter(sub_part__trackable=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 = [
|
||||||
|
@ -17,7 +17,11 @@ function getAvailableTableFilters(tableKey) {
|
|||||||
trackable: {
|
trackable: {
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
title: '{% trans "Trackable Part" %}'
|
title: '{% trans "Trackable Part" %}'
|
||||||
}
|
},
|
||||||
|
validated: {
|
||||||
|
type: 'bool',
|
||||||
|
title: '{% trans "Validated" %}',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user