Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Get rid of payment_sttaus filter from order where (#17764)
Iga Karbowiakff5f6ca630e3
diff --git a/saleor/graphql/order/filters.py b/saleor/graphql/order/filters.pyindex d7073bea5e..041f24915d 100644--- a/saleor/graphql/order/filters.py+++ b/saleor/graphql/order/filters.py@@ -14,7 +14,6 @@ from ...giftcard.models import GiftCardEventfrom ...order.models import Order, OrderLinefrom ...order.search import search_ordersfrom ...payment import ChargeStatus-from ...payment.models import Paymentfrom ...product.models import ProductVariantfrom ..channel.filters import get_currency_from_filter_datafrom ..core.doc_category import DOC_CATEGORY_ORDERS@@ -323,18 +322,6 @@ class OrderStatusEnumFilterInput(BaseInputObjectType):description = "Filter by order status."-class PaymentStatusEnumFilterInput(BaseInputObjectType):- eq = PaymentChargeStatusEnum(description=FilterInputDescriptions.EQ, required=False)- one_of = NonNullList(- PaymentChargeStatusEnum,- description=FilterInputDescriptions.ONE_OF,- required=False,- )-- class Meta:- doc_category = DOC_CATEGORY_ORDERS--class OrderAuthorizeStatusEnumFilterInput(BaseInputObjectType):eq = OrderAuthorizeStatusEnum(description=FilterInputDescriptions.EQ, required=False@@ -396,11 +383,6 @@ class OrderWhere(WhereFilterSet):method="filter_user_email",help_text="Filter by user email.",)- payment_status = OperationObjectTypeWhereFilter(- input_class=PaymentStatusEnumFilterInput,- method="filter_payment_status",- help_text="Filter by payment status.",- )authorize_status = OperationObjectTypeWhereFilter(input_class=OrderAuthorizeStatusEnumFilterInput,method="filter_authorize_status",@@ -469,24 +451,6 @@ class OrderWhere(WhereFilterSet):def filter_user_email(qs, _, value):return filter_where_by_value_field(qs, "user_email", value)- @staticmethod- def filter_payment_status(qs, _, value):- if value is None:- return qs.none()-- eq_value = value.get("eq")- values = value.get("one_of")- if eq_value:- values = [eq_value]-- if values:- lookup = Q(is_active=True, charge_status__in=values)- if ChargeStatus.FULLY_REFUNDED in values:- lookup |= Q(charge_status=ChargeStatus.FULLY_REFUNDED)- payments = Payment.objects.using(qs.db).filter(lookup)- return qs.filter(Exists(payments.filter(order_id=OuterRef("id"))))- return qs.none()-@staticmethoddef filter_authorize_status(qs, _, value):return filter_where_by_value_field(qs, "authorize_status", value)diff --git a/saleor/graphql/order/tests/queries/test_order_with_where.py b/saleor/graphql/order/tests/queries/test_order_with_where.pyindex 980809ccce..e39ca14d1c 100644--- a/saleor/graphql/order/tests/queries/test_order_with_where.py+++ b/saleor/graphql/order/tests/queries/test_order_with_where.py@@ -13,9 +13,6 @@ from .....order.models import Orderfrom .....order.search import (prepare_order_search_vector_value,)-from .....payment import ChargeStatus-from .....payment.models import Payment-from ....payment.enums import PaymentChargeStatusEnumfrom ....tests.utils import get_graphql_content, get_graphql_content_from_responseORDERS_WHERE_QUERY = """@@ -601,62 +598,6 @@ def test_order_filter_by_channel_id_none(assert len(orders) == 0- ("where", "indexes"),- [- ({"eq": PaymentChargeStatusEnum.NOT_CHARGED.name}, [0]),- ({"oneOf": [PaymentChargeStatusEnum.CANCELLED.name]}, [1]),- ({"oneOf": [PaymentChargeStatusEnum.FULLY_CHARGED.name]}, [2]),- (- {- "oneOf": [- PaymentChargeStatusEnum.CANCELLED.name,- PaymentChargeStatusEnum.FULLY_CHARGED.name,- ]- },- [1, 2],- ),- ({"eq": PaymentChargeStatusEnum.FULLY_REFUNDED.name}, []),- ({}, []),- ({"oneOf": []}, []),- ({"eq": None}, []),- (None, []),- ],-)-def test_order_filter_by_payment_status(- where,- indexes,- staff_api_client,- order_list,- payments_dummy,- permission_group_manage_orders,- channel_USD,-):- # given- permission_group_manage_orders.user_set.add(staff_api_client.user)-- payments_dummy[0].order = order_list[0]- payments_dummy[0].charge_status = ChargeStatus.NOT_CHARGED- payments_dummy[1].order = order_list[1]- payments_dummy[1].charge_status = ChargeStatus.CANCELLED- payments_dummy[2].order = order_list[2]- payments_dummy[2].charge_status = ChargeStatus.FULLY_CHARGED- Payment.objects.bulk_update(payments_dummy, ["order", "charge_status"])- variables = {- "where": {"paymentStatus": where},- }-- # when- response = staff_api_client.post_graphql(ORDERS_WHERE_QUERY, variables)-- # then- content = get_graphql_content(response)- orders = content["data"]["orders"]["edges"]- assert len(orders) == len(indexes)- numbers = {node["node"]["number"] for node in orders}- assert numbers == {str(order_list[index].number) for index in indexes}--@pytest.mark.parametrize(("where", "indexes"),[diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex d69d26fa27..c895969f10 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -12785,9 +12785,6 @@ input OrderWhereInput @doc(category: "Orders") {"""Filter by user email."""userEmail: StringFilterInput- """Filter by payment status."""- paymentStatus: PaymentStatusEnumFilterInput-"""Filter by authorize status."""authorizeStatus: OrderAuthorizeStatusEnumFilterInput@@ -12836,14 +12833,6 @@ input IntFilterInput {range: IntRangeInput}-input PaymentStatusEnumFilterInput @doc(category: "Orders") {- """The value equal to."""- eq: PaymentChargeStatusEnum-- """The value included in."""- oneOf: [PaymentChargeStatusEnum!]-}-"""Filter by authorize status."""input OrderAuthorizeStatusEnumFilterInput @doc(category: "Orders") {"""The value equal to."""