diff --git a/app/apps/cases/views/case.py b/app/apps/cases/views/case.py index 4deb18768..a7bacc0d0 100644 --- a/app/apps/cases/views/case.py +++ b/app/apps/cases/views/case.py @@ -174,7 +174,7 @@ class CaseFilter(filters.FilterSet): queryset=Tag.objects.all(), method="get_tag" ) task = filters.ModelMultipleChoiceFilter( - queryset=CaseUserTask.objects.filter(completed=False), + queryset=CaseUserTask.objects.all(), method="get_task", to_field_name="task_name", ) @@ -294,6 +294,8 @@ def get_state_types(self, queryset, name, value): return queryset def get_task(self, queryset, name, value): + # Filter here instead of the queryset to prevent exceptions when there are no open tasks with a speciifc state + value = [task for task in value if not task.completed] if value: return queryset.filter( workflows__completed=False,