diff --git a/InvenTree/InvenTree/status_codes.py b/InvenTree/InvenTree/status_codes.py index 2082eac70b..f8089cb5de 100644 --- a/InvenTree/InvenTree/status_codes.py +++ b/InvenTree/InvenTree/status_codes.py @@ -147,6 +147,11 @@ class SalesOrderStatus(StatusCode): RETURNED: 'yellow', } + # Open orders + OPEN = [ + PENDING, + ] + class StockStatus(StatusCode): diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index 0c1ef8b3ae..a7915878c5 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -13,7 +13,7 @@ from django.conf.urls import url, include from InvenTree.helpers import str2bool from InvenTree.api import AttachmentMixin -from InvenTree.status_codes import PurchaseOrderStatus +from InvenTree.status_codes import PurchaseOrderStatus, SalesOrderStatus from part.models import Part from company.models import SupplierPart @@ -271,6 +271,17 @@ class SOList(generics.ListCreateAPIView): params = self.request.query_params + # Filter by 'outstanding' status + outstanding = params.get('outstanding', None) + + if outstanding is not None: + outstanding = str2bool(outstanding) + + if outstanding: + queryset = queryset.filter(status__in=SalesOrderStatus.OPEN) + else: + queryset = queryset.exclude(status__in=SalesOrderStatus.OPEN) + status = params.get('status', None) if status is not None: diff --git a/InvenTree/templates/js/table_filters.html b/InvenTree/templates/js/table_filters.html index 285abb36f9..bec29b0487 100644 --- a/InvenTree/templates/js/table_filters.html +++ b/InvenTree/templates/js/table_filters.html @@ -97,6 +97,10 @@ function getAvailableTableFilters(tableKey) { title: '{% trans "Order status" %}', options: salesOrderCodes, }, + outstanding: { + type: 'bool', + title: '{% trans "Outstanding" %}', + }, }; }