Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Do not update draft order addresses when user is changing (#7088)
Iga Karbowiakd11abd630796
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6206d0e63a..f58006b04b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,7 @@ All notable, unreleased changes to this project will be documented in this file.- Fix invalid tax rates for lines - #7058 by @IKarbowiak- Allow seeing unconfirmed orders - #7072 by @IKarbowiak- Raise GraphQLError when too big integer value is provided - #7076 by @IKarbowiak+- Do not update draft order addresses when user is changing - #7088 by @IKarbowiak- Recalculate draft order when product/variant was deleted - #7085 by @d-wysocki- Added validation for `DraftOrderCreate` with negative quantity line - #7085 by @d-wysocki- Remove html tags from product description_plaintext - #7094 by @d-wysockidiff --git a/saleor/graphql/account/i18n.py b/saleor/graphql/account/i18n.pyindex 282d303015..3f3a98fe18 100644--- a/saleor/graphql/account/i18n.py+++ b/saleor/graphql/account/i18n.py@@ -1,3 +1,5 @@+from typing import Dict, Optional+from django.core.exceptions import ValidationErrorfrom ...account.forms import get_address_form@@ -20,8 +22,11 @@ class I18nMixin:pass@classmethod- def validate_address_form(cls, address_data: dict, instance=None):+ def validate_address_form(+ cls, address_data: dict, address_type: Optional[str] = None, instance=None+ ):phone = address_data.get("phone", None)+ params = {"address_type": address_type} if address_type else {}if phone:try:validate_possible_number(phone, address_data.get("country"))@@ -29,7 +34,9 @@ class I18nMixin:raise ValidationError({"phone": ValidationError(- f"'{phone}' is not a valid phone number.", code=exc.code+ f"'{phone}' is not a valid phone number.",+ code=exc.code,+ params=params,)}) from exc@@ -38,16 +45,37 @@ class I18nMixin:address_data, address_data.get("country"), instance=instance)if not address_form.is_valid():- raise ValidationError(address_form.errors.as_data())+ errors = cls.attach_params_to_address_form_errors(address_form, params)+ raise ValidationError(errors)return address_form@classmethod- def validate_address(cls, address_data: dict, instance=None, info=None):+ def attach_params_to_address_form_errors(cls, address_form, params: Dict[str, str]):+ errors_dict = address_form.errors.as_data()+ for errors in errors_dict.values():+ for error in errors:+ error.params = params+ return errors_dict++ @classmethod+ def validate_address(+ cls,+ address_data: dict,+ *,+ address_type: Optional[str] = None,+ instance: Optional[Address] = None,+ info=None+ ):if address_data.get("country") is None:+ params = {"address_type": address_type} if address_type else {}raise ValidationError(- {"country": ValidationError("This field is required.", code="required")}+ {+ "country": ValidationError(+ "This field is required.", code="required", params=params+ )+ })- address_form = cls.validate_address_form(address_data)+ address_form = cls.validate_address_form(address_data, address_type)if not instance:instance = Address()diff --git a/saleor/graphql/account/mutations/account.py b/saleor/graphql/account/mutations/account.pyindex 75fad0f168..4edfa79b7b 100644--- a/saleor/graphql/account/mutations/account.py+++ b/saleor/graphql/account/mutations/account.py@@ -280,7 +280,7 @@ class AccountAddressCreate(ModelMutation, I18nMixin):cleaned_input = cls.clean_input(info=info, instance=Address(), data=data.get("input"))- address = cls.validate_address(cleaned_input)+ address = cls.validate_address(cleaned_input, address_type=address_type)cls.clean_instance(info, address)cls.save(info, address, cleaned_input)cls._save_m2m(info, address, cleaned_input)diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.pyindex 66a480e0c1..ae502f8e27 100644--- a/saleor/graphql/account/mutations/base.py+++ b/saleor/graphql/account/mutations/base.py@@ -11,6 +11,7 @@ from ....account.notifications import (send_password_reset_notification,send_set_password_notification,)+from ....checkout import AddressTypefrom ....core.exceptions import PermissionDeniedfrom ....core.permissions import AccountPermissionsfrom ....core.utils.url import validate_storefront_url@@ -393,6 +394,7 @@ class BaseCustomerCreate(ModelMutation, I18nMixin):if shipping_address_data:shipping_address = cls.validate_address(shipping_address_data,+ address_type=AddressType.SHIPPING,instance=getattr(instance, SHIPPING_ADDRESS_FIELD),info=info,)@@ -401,6 +403,7 @@ class BaseCustomerCreate(ModelMutation, I18nMixin):if billing_address_data:billing_address = cls.validate_address(billing_address_data,+ address_type=AddressType.BILLING,instance=getattr(instance, BILLING_ADDRESS_FIELD),info=info,)diff --git a/saleor/graphql/account/tests/test_account.py b/saleor/graphql/account/tests/test_account.pyindex 5a0b308b5c..e060fe752b 100644--- a/saleor/graphql/account/tests/test_account.py+++ b/saleor/graphql/account/tests/test_account.py@@ -1445,7 +1445,9 @@ ACCOUNT_UPDATE_QUERY = """}) {errors {field+ codemessage+ addressType}user {firstName@@ -1527,6 +1529,44 @@ def test_logged_customer_update_addresses(user_api_client, graphql_address_data)assert user.default_shipping_address.first_name == new_first_name+def test_logged_customer_update_addresses_invalid_shipping_address(+ user_api_client, graphql_address_data+):+ shipping_address = graphql_address_data.copy()+ del shipping_address["country"]++ query = ACCOUNT_UPDATE_QUERY+ mutation_name = "accountUpdate"+ variables = {"billing": graphql_address_data, "shipping": shipping_address}+ response = user_api_client.post_graphql(query, variables)+ content = get_graphql_content(response)+ data = content["data"][mutation_name]+ assert len(data["errors"]) == 1+ errors = data["errors"]+ assert errors[0]["field"] == "country"+ assert errors[0]["code"] == AccountErrorCode.REQUIRED.name+ assert errors[0]["addressType"] == AddressType.SHIPPING.upper()+++def test_logged_customer_update_addresses_invalid_billing_address(+ user_api_client, graphql_address_data+):+ billing_address = graphql_address_data.copy()+ del billing_address["country"]++ query = ACCOUNT_UPDATE_QUERY+ mutation_name = "accountUpdate"+ variables = {"billing": billing_address, "shipping": graphql_address_data}+ response = user_api_client.post_graphql(query, variables)+ content = get_graphql_content(response)+ data = content["data"][mutation_name]+ assert len(data["errors"]) == 1+ errors = data["errors"]+ assert errors[0]["field"] == "country"+ assert errors[0]["code"] == AccountErrorCode.REQUIRED.name+ assert errors[0]["addressType"] == AddressType.BILLING.upper()++def test_logged_customer_update_anonymous_user(api_client):query = ACCOUNT_UPDATE_QUERYresponse = api_client.post_graphql(query, {})@@ -3615,6 +3655,11 @@ mutation($addressInput: AddressInput!, $addressType: AddressTypeEnum) {user {}+ errors {+ code+ field+ addressType+ }}}"""@@ -3700,8 +3745,15 @@ def test_address_not_created_after_validation_fails(address_type = AddressType.SHIPPING.upper()variables = {"addressInput": graphql_address_data, "addressType": address_type}- user_api_client.post_graphql(query, variables)+ response = user_api_client.post_graphql(query, variables)+ content = get_graphql_content(response)+ data = content["data"]["accountAddressCreate"]+ assert not data["address"]+ assert len(data["errors"]) == 1+ assert data["errors"][0]["code"] == AccountErrorCode.INVALID.name+ assert data["errors"][0]["field"] == "postalCode"+ assert data["errors"][0]["addressType"] == address_typeuser.refresh_from_db()assert user.addresses.count() == nr_of_addressesdiff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex f5af437c90..fbcb396736 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -10,7 +10,7 @@ from django.db.models import Qfrom ...channel.exceptions import ChannelNotDefinedfrom ...channel.models import Channelfrom ...channel.utils import get_default_channel-from ...checkout import models+from ...checkout import AddressType, modelsfrom ...checkout.complete_checkout import complete_checkoutfrom ...checkout.error_codes import CheckoutErrorCodefrom ...checkout.fetch import (@@ -256,7 +256,9 @@ class CheckoutCreate(ModelMutation, I18nMixin):@classmethoddef retrieve_shipping_address(cls, user, data: dict) -> Optional[models.Address]:if data.get("shipping_address") is not None:- return cls.validate_address(data["shipping_address"])+ return cls.validate_address(+ data["shipping_address"], address_type=AddressType.SHIPPING+ )if user.is_authenticated:return user.default_shipping_addressreturn None@@ -264,7 +266,9 @@ class CheckoutCreate(ModelMutation, I18nMixin):@classmethoddef retrieve_billing_address(cls, user, data: dict) -> Optional[models.Address]:if data.get("billing_address") is not None:- return cls.validate_address(data["billing_address"])+ return cls.validate_address(+ data["billing_address"], address_type=AddressType.BILLING+ )if user.is_authenticated:return user.default_billing_addressreturn None@@ -662,7 +666,10 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):)shipping_address = cls.validate_address(- shipping_address, instance=checkout.shipping_address, info=info+ shipping_address,+ address_type=AddressType.SHIPPING,+ instance=checkout.shipping_address,+ info=info,)discounts = info.context.discounts@@ -713,7 +720,10 @@ class CheckoutBillingAddressUpdate(CheckoutShippingAddressUpdate):info, checkout_id, only_type=Checkout, field="checkout_id")billing_address = cls.validate_address(- billing_address, instance=checkout.billing_address, info=info+ billing_address,+ address_type=AddressType.BILLING,+ instance=checkout.billing_address,+ info=info,)with transaction.atomic():billing_address.save()diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex 2fd23fc489..ecedbcb492 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -15,7 +15,7 @@ from prices import Money, TaxedMoneyfrom ....account.models import Userfrom ....channel.utils import DEPRECATION_WARNING_MESSAGE-from ....checkout import calculations+from ....checkout import AddressType, calculationsfrom ....checkout.checkout_cleaner import (clean_checkout_payment,clean_checkout_shipping,@@ -124,6 +124,7 @@ MUTATION_CHECKOUT_CREATE = """messagecodevariants+ addressType}}}@@ -744,6 +745,7 @@ def test_checkout_create_cannot_add_invalid_quantities("message": expected_error_message,"code": error_code.name,"variants": None,+ "addressType": None,}]@@ -821,6 +823,7 @@ def test_checkout_create_required_country_shipping_address(checkout_errors = content["data"]["checkoutCreate"]["errors"]assert checkout_errors[0]["field"] == "country"assert checkout_errors[0]["code"] == CheckoutErrorCode.REQUIRED.name+ assert checkout_errors[0]["addressType"] == AddressType.SHIPPING.upper()def test_checkout_create_required_country_billing_address(@@ -845,6 +848,7 @@ def test_checkout_create_required_country_billing_address(checkout_errors = content["data"]["checkoutCreate"]["errors"]assert checkout_errors[0]["field"] == "country"assert checkout_errors[0]["code"] == CheckoutErrorCode.REQUIRED.name+ assert checkout_errors[0]["addressType"] == AddressType.BILLING.upper()def test_checkout_create_default_email_for_logged_in_customer(diff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.pyindex de9d3d7576..8d39bfa0bc 100644--- a/saleor/graphql/core/types/common.py+++ b/saleor/graphql/core/types/common.py@@ -5,6 +5,7 @@ from django.conf import settingsfrom ....core.tracing import traced_resolverfrom ....product.product_images import get_thumbnail+from ...account.enums import AddressTypeEnumfrom ..enums import (AccountErrorCode,AppErrorCode,@@ -80,6 +81,9 @@ class Error(graphene.ObjectType):class AccountError(Error):code = AccountErrorCode(description="The error code.", required=True)+ address_type = AddressTypeEnum(+ description="A type of address that causes the error.", required=False+ )class AppError(Error):@@ -129,6 +133,9 @@ class CheckoutError(Error):description="List of varint IDs which causes the error.",required=False,)+ address_type = AddressTypeEnum(+ description="A type of address that causes the error.", required=False+ )class ProductWithoutVariantError(Error):@@ -178,6 +185,9 @@ class OrderError(Error):description="List of product variants that are associated with the error",required=False,)+ address_type = AddressTypeEnum(+ description="A type of address that causes the error.", required=False+ )class InvoiceError(Error):diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.pyindex 91f660f109..86f2ca6be5 100644--- a/saleor/graphql/order/mutations/draft_orders.py+++ b/saleor/graphql/order/mutations/draft_orders.py@@ -4,6 +4,7 @@ from django.db import transactionfrom graphene.types import InputObjectTypefrom ....account.models import User+from ....checkout import AddressTypefrom ....core.exceptions import InsufficientStockfrom ....core.permissions import OrderPermissionsfrom ....core.taxes import TaxError, zero_taxed_money@@ -173,16 +174,12 @@ class DraftOrderCreate(ModelMutation, I18nMixin):display_gross_prices = info.context.site.settings.display_gross_pricescleaned_input["display_gross_prices"] = display_gross_prices- # Set up default addresses if possible- user = cleaned_input.get("user")- if user and not shipping_address:- cleaned_input["shipping_address"] = user.default_shipping_address- if user and not billing_address:- cleaned_input["billing_address"] = user.default_billing_address-if shipping_address:shipping_address = cls.validate_address(- shipping_address, instance=instance.shipping_address, info=info+ shipping_address,+ address_type=AddressType.SHIPPING,+ instance=instance.shipping_address,+ info=info,)shipping_address = info.context.plugins.change_user_address(shipping_address, "shipping", user=instance@@ -190,7 +187,10 @@ class DraftOrderCreate(ModelMutation, I18nMixin):cleaned_input["shipping_address"] = shipping_addressif billing_address:billing_address = cls.validate_address(- billing_address, instance=instance.billing_address, info=info+ billing_address,+ address_type=AddressType.BILLING,+ instance=instance.billing_address,+ info=info,)billing_address = info.context.plugins.change_user_address(billing_address, "billing", user=instancediff --git a/saleor/graphql/order/tests/test_order.py b/saleor/graphql/order/tests/test_order.pyindex fe42889550..79fbc95d22 100644--- a/saleor/graphql/order/tests/test_order.py+++ b/saleor/graphql/order/tests/test_order.py@@ -14,6 +14,7 @@ from measurement.measures import Weightfrom prices import Money, TaxedMoneyfrom ....account.models import CustomerEvent+from ....checkout import AddressTypefrom ....core.anonymize import obfuscate_emailfrom ....core.notify_events import NotifyEventTypefrom ....core.prices import quantize_price@@ -1250,12 +1251,14 @@ def test_query_order_as_app(app_api_client, permission_manage_orders, order):DRAFT_ORDER_CREATE_MUTATION = """mutation draftCreate($user: ID, $discount: PositiveDecimal, $lines: [OrderLineCreateInput],- $shippingAddress: AddressInput, $shippingMethod: ID, $voucher: ID,- $customerNote: String, $channel: ID, $redirectUrl: String+ $shippingAddress: AddressInput, $billingAddress: AddressInput,+ $shippingMethod: ID, $voucher: ID, $customerNote: String, $channel: ID,+ $redirectUrl: String) {draftOrderCreate(input: {user: $user, discount: $discount,lines: $lines, shippingAddress: $shippingAddress,+ billingAddress: $billingAddress,shippingMethod: $shippingMethod, voucher: $voucher,channel: $channel,redirectUrl: $redirectUrl,@@ -1265,6 +1268,7 @@ DRAFT_ORDER_CREATE_MUTATION = """codevariantsmessage+ addressType}order {discount {@@ -1277,6 +1281,16 @@ DRAFT_ORDER_CREATE_MUTATION = """productSkuquantity}+ billingAddress{+ city+ streetAddress1+ postalCode+ }+ shippingAddress{+ city+ streetAddress1+ postalCode+ }statusvoucher {code@@ -1328,6 +1342,7 @@ def test_draft_order_create("user": user_id,"discount": discount,"lines": variant_list,+ "billingAddress": shipping_address,"shippingAddress": shipping_address,"shippingMethod": shipping_id,"voucher": voucher_id,@@ -1345,17 +1360,20 @@ def test_draft_order_create(assert data["voucher"]["code"] == voucher.codeassert data["customerNote"] == customer_noteassert data["redirectUrl"] == redirect_url+ assert (+ data["billingAddress"]["streetAddress1"]+ == graphql_address_data["streetAddress1"]+ )+ assert (+ data["shippingAddress"]["streetAddress1"]+ == graphql_address_data["streetAddress1"]+ )order = Order.objects.first()assert order.user == customer_user- # billing address should be copied- assert order.billing_address.pk != customer_user.default_billing_address.pk- assert (- order.billing_address.as_data()- == customer_user.default_billing_address.as_data()- )assert order.shipping_method == shipping_method- assert order.shipping_address.first_name == graphql_address_data["firstName"]+ assert order.billing_address+ assert order.shipping_address# Ensure the correct event was createdcreated_draft_event = OrderEvent.objects.get(@@ -1423,12 +1441,8 @@ def test_draft_order_create_with_inactive_channel(order = Order.objects.first()assert order.user == customer_user- # billing address should be copied- assert order.billing_address.pk != customer_user.default_billing_address.pk- assert (- order.billing_address.as_data()- == customer_user.default_billing_address.as_data()- )+ # billing address shouldn't be set+ assert not order.billing_addressassert order.shipping_method == shipping_methodassert order.shipping_address.first_name == graphql_address_data["firstName"]@@ -1488,12 +1502,8 @@ def test_draft_order_create_variant_with_0_price(order = Order.objects.first()assert order.user == customer_user- # billing address should be copied- assert order.billing_address.pk != customer_user.default_billing_address.pk- assert (- order.billing_address.as_data()- == customer_user.default_billing_address.as_data()- )+ # billing address shouldn't be copied from user+ assert not order.billing_addressassert order.shipping_method == shipping_methodassert order.shipping_address.first_name == graphql_address_data["firstName"]@@ -1951,11 +1961,7 @@ def test_draft_order_create_with_channel(assert order.user == customer_userassert order.channel.id == channel_USD.id# billing address should be copied- assert order.billing_address.pk != customer_user.default_billing_address.pk- assert (- order.billing_address.as_data()- == customer_user.default_billing_address.as_data()- )+ assert not order.billing_addressassert order.shipping_method == shipping_methodassert order.shipping_address.first_name == graphql_address_data["firstName"]@@ -1967,6 +1973,126 @@ def test_draft_order_create_with_channel(assert created_draft_event.parameters == {}+def test_draft_order_create_invalid_billing_address(+ staff_api_client,+ permission_manage_orders,+ staff_user,+ customer_user,+ product_without_shipping,+ shipping_method,+ variant,+ voucher,+ channel_USD,+ graphql_address_data,+):+ variant_0 = variant+ query = DRAFT_ORDER_CREATE_MUTATION++ # Ensure no events were created yet+ assert not OrderEvent.objects.exists()++ user_id = graphene.Node.to_global_id("User", customer_user.id)+ variant_0_id = graphene.Node.to_global_id("ProductVariant", variant_0.id)+ variant_1 = product_without_shipping.variants.first()+ variant_1.quantity = 2+ variant_1.save()+ variant_1_id = graphene.Node.to_global_id("ProductVariant", variant_1.id)+ discount = "10"+ customer_note = "Test note"+ variant_list = [+ {"variantId": variant_0_id, "quantity": 2},+ {"variantId": variant_1_id, "quantity": 1},+ ]+ billing_address = graphql_address_data.copy()+ del billing_address["country"]+ shipping_id = graphene.Node.to_global_id("ShippingMethod", shipping_method.id)+ voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ redirect_url = "https://www.example.com"++ variables = {+ "user": user_id,+ "discount": discount,+ "lines": variant_list,+ "billingAddress": billing_address,+ "shippingAddress": graphql_address_data,+ "shippingMethod": shipping_id,+ "voucher": voucher_id,+ "customerNote": customer_note,+ "channel": channel_id,+ "redirectUrl": redirect_url,+ }+ response = staff_api_client.post_graphql(+ query, variables, permissions=[permission_manage_orders]+ )+ content = get_graphql_content(response)+ errors = content["data"]["draftOrderCreate"]["errors"]+ assert len(errors) == 1+ assert errors[0]["field"] == "country"+ assert errors[0]["code"] == OrderErrorCode.REQUIRED.name+ assert errors[0]["addressType"] == AddressType.BILLING.upper()+++def test_draft_order_create_invalid_shipping_address(+ staff_api_client,+ permission_manage_orders,+ staff_user,+ customer_user,+ product_without_shipping,+ shipping_method,+ variant,+ voucher,+ channel_USD,+ graphql_address_data,+):+ variant_0 = variant+ query = DRAFT_ORDER_CREATE_MUTATION++ # Ensure no events were created yet+ assert not OrderEvent.objects.exists()++ user_id = graphene.Node.to_global_id("User", customer_user.id)+ variant_0_id = graphene.Node.to_global_id("ProductVariant", variant_0.id)+ variant_1 = product_without_shipping.variants.first()+ variant_1.quantity = 2+ variant_1.save()+ variant_1_id = graphene.Node.to_global_id("ProductVariant", variant_1.id)+ discount = "10"+ customer_note = "Test note"+ variant_list = [+ {"variantId": variant_0_id, "quantity": 2},+ {"variantId": variant_1_id, "quantity": 1},+ ]+ shipping_address = graphql_address_data.copy()+ del shipping_address["country"]+ shipping_id = graphene.Node.to_global_id("ShippingMethod", shipping_method.id)+ voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)+ redirect_url = "https://www.example.com"++ variables = {+ "user": user_id,+ "discount": discount,+ "lines": variant_list,+ "billingAddress": graphql_address_data,+ "shippingAddress": shipping_address,+ "shippingMethod": shipping_id,+ "voucher": voucher_id,+ "customerNote": customer_note,+ "channel": channel_id,+ "redirectUrl": redirect_url,+ }+ response = staff_api_client.post_graphql(+ query, variables, permissions=[permission_manage_orders]+ )+ content = get_graphql_content(response)+ errors = content["data"]["draftOrderCreate"]["errors"]+ assert len(errors) == 1+ assert errors[0]["field"] == "country"+ assert errors[0]["code"] == OrderErrorCode.REQUIRED.name+ assert errors[0]["addressType"] == AddressType.SHIPPING.upper()++DRAFT_UPDATE_QUERY = """mutation draftUpdate($id: ID!,diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex c131e6a921..928c5a8c6a 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -34,6 +34,7 @@ type AccountError {field: Stringmessage: Stringcode: AccountErrorCode!+ addressType: AddressTypeEnum}enum AccountErrorCode {@@ -982,6 +983,7 @@ type CheckoutError {message: Stringcode: CheckoutErrorCode!variants: [ID!]+ addressType: AddressTypeEnum}enum CheckoutErrorCode {@@ -3105,6 +3107,7 @@ type OrderError {warehouse: IDorderLine: IDvariants: [ID!]+ addressType: AddressTypeEnum}enum OrderErrorCode {@@ -5304,6 +5307,7 @@ type StaffError {field: Stringmessage: Stringcode: AccountErrorCode!+ addressType: AddressTypeEnumpermissions: [PermissionEnum!]groups: [ID!]users: [ID!]diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.pyindex 4c1164f622..0d40b0329b 100644--- a/saleor/graphql/shop/mutations.py+++ b/saleor/graphql/shop/mutations.py@@ -119,7 +119,9 @@ class ShopAddressUpdate(BaseMutation, I18nMixin):company_address = account_models.Address()else:company_address = site_settings.company_address- company_address = cls.validate_address(data, company_address, info=info)+ company_address = cls.validate_address(+ data, instance=company_address, info=info+ )company_address.save()site_settings.company_address = company_addresssite_settings.save(update_fields=["company_address"])