Add ability to filter BOM status by "validated" field

This commit is contained in:
Oliver Walters 2020-10-26 14:43:43 +11:00
parent 24ab48ef4c
commit 8f108d42d2
2 changed files with 24 additions and 1 deletions

View File

@ -768,6 +768,25 @@ class BomList(generics.ListCreateAPIView):
trackable = str2bool(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
filter_backends = [

View File

@ -17,7 +17,11 @@ function getAvailableTableFilters(tableKey) {
trackable: {
type: 'bool',
title: '{% trans "Trackable Part" %}'
}
},
validated: {
type: 'bool',
title: '{% trans "Validated" %}',
},
};
}