Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix filtering on shipped and cancelled orders
Anna Siwik68e4cc8035b2
diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 1ed91f6963..b72b6e147b 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -5,6 +5,7 @@ from django.conf import settingsfrom django.core.exceptions import ObjectDoesNotExistfrom django.core.validators import MaxValueValidator, MinValueValidatorfrom django.db import models+from django.db.models import Qfrom django.urls import reversefrom django.utils.timezone import nowfrom django.utils.translation import pgettext_lazy@@ -34,11 +35,13 @@ class OrderQuerySet(models.QuerySet):def shipped(self):"""Returns queryset containg orders with SHIPPED status."""statuses = {OrderStatus.SHIPPED, OrderStatus.CANCELLED}- return self.filter(groups__status__in=statuses)+ return self.filter(groups__status__in=statuses).filter(+ groups__status__in={OrderStatus.SHIPPED})def cancelled(self):"""Returns queryset containg orders with CANCELLED status."""- return self.filter(groups__status__in={OrderStatus.CANCELLED})+ return self.filter(+ Q(groups__status__in={OrderStatus.CANCELLED}) | Q(groups=None))class Order(models.Model, ItemSet):