Fix filtering for build orders

This commit is contained in:
Oliver 2021-07-13 19:58:47 +10:00
parent 2295008944
commit a0b3359d62

View File

@ -68,10 +68,6 @@ class BuildList(generics.ListCreateAPIView):
filters.OrderingFilter, filters.OrderingFilter,
] ]
filter_fields = [
'sales_order',
]
ordering_fields = [ ordering_fields = [
'reference', 'reference',
'part__name', 'part__name',
@ -114,6 +110,12 @@ class BuildList(generics.ListCreateAPIView):
if parent is not None: if parent is not None:
queryset = queryset.filter(parent=parent) queryset = queryset.filter(parent=parent)
# Filter by sales_order
sales_order = params.get('sales_order', None)
if sales_order is not None:
queryset = queryset.filter(sales_order=sales_order)
# Filter by "ancestor" builds # Filter by "ancestor" builds
ancestor = params.get('ancestor', None) ancestor = params.get('ancestor', None)