mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-06 12:01:41 +00:00
Enhance status filter for orders
This commit is contained in:
@@ -82,8 +82,14 @@ class OrderFilter(rest_filters.FilterSet):
|
||||
status = rest_filters.NumberFilter(label=_('Order Status'), method='filter_status')
|
||||
|
||||
def filter_status(self, queryset, name, value):
|
||||
"""Filter by integer status code."""
|
||||
return queryset.filter(status=value)
|
||||
"""Filter by integer status code.
|
||||
|
||||
Note: Also account for the possibility of a custom status code.
|
||||
"""
|
||||
q1 = Q(status=value, status_custom_key__isnull=True)
|
||||
q2 = Q(status_custom_key=value)
|
||||
|
||||
return queryset.filter(q1 | q2).distinct()
|
||||
|
||||
# Exact match for reference
|
||||
reference = rest_filters.CharFilter(
|
||||
|
@@ -571,7 +571,10 @@ class StockFilter(rest_filters.FilterSet):
|
||||
status = rest_filters.NumberFilter(label=_('Status Code'), method='filter_status')
|
||||
|
||||
def filter_status(self, queryset, name, value):
|
||||
"""Filter by integer status code."""
|
||||
"""Filter by integer status code.
|
||||
|
||||
Note: Also account for the possibility of a custom status code.
|
||||
"""
|
||||
q1 = Q(status=value, status_custom_key__isnull=True)
|
||||
q2 = Q(status_custom_key=value)
|
||||
|
||||
|
Reference in New Issue
Block a user