Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Dashboard-1 no longer fails when updating an order address phone number

NyanKiyoshic4a614272be4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b34dbe1c9..a82aa63231 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Remove unused decorator - #4036 by @maarcingebala
- Overall improvement of the GraphQL performances, especially on single nodes - #3968 @NyanKiyoshi
- Remove unnecessary dedents from GraphQL schema so new Playground can work - #4045 by @salwator
+- Fix crash on dashboard 1.0 when updating an order address's phone number - #4061 by @NyanKiyoshi
## 2.5.0
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index a9f0b2c663..f985c05378 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -5,8 +5,7 @@ from django.urls import reverse, reverse_lazy
from django.utils.translation import npgettext_lazy, pgettext_lazy
from ...account.i18n import (
- AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField,
- clean_phone_for_country)
+ AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField)
from ...account.models import User
from ...checkout.forms import QuantityField
from ...core.exceptions import InsufficientStock
@@ -591,13 +590,6 @@ class AddressForm(StorefrontAddressForm):
def clean(self):
data = super().clean()
- phone = data.get('phone')
- country = data.get('country')
- if phone:
- try:
- data['phone'] = clean_phone_for_country(phone, country)
- except forms.ValidationError as error:
- self.add_error('phone', error)
return data
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
index 2c090319a7..18408c8b78 100644
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -3,6 +3,7 @@ from decimal import Decimal
import pytest
from django.urls import reverse
+from phonenumber_field.phonenumber import PhoneNumber
from prices import Money
from saleor.checkout import AddressType
@@ -750,6 +751,33 @@ def test_view_order_shipping_edit_not_draft_order(
assert response.status_code == 404
+def test_view_order_address_edit(
+ admin_client, order_with_lines, address_other_country):
+
+ order = order_with_lines
+ new_address = address_other_country
+
+ new_address.phone = PhoneNumber.from_string(
+ region=new_address.country.code, phone_number='+33.600000000')
+
+ address_data = new_address.as_data()
+ address_data.pop('phone')
+
+ address_data.update({
+ 'phone_0': '+33',
+ 'phone_1': '600000000'})
+
+ url = reverse(
+ 'dashboard:address-edit',
+ kwargs={'order_pk': order.pk, 'address_type': 'shipping'})
+
+ response = admin_client.post(url, address_data)
+ assert response.status_code == 302
+
+ order.refresh_from_db(fields=['shipping_address'])
+ assert new_address.as_data() == order.shipping_address.as_data()
+
+
def test_view_order_shipping_remove(admin_client, draft_order):
url = reverse(
'dashboard:order-shipping-remove', kwargs={'order_pk': draft_order.pk})