From 1fcf4797dc6dbe9c69770db7261d15eee96190e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 8 Sep 2025 14:05:05 +0200 Subject: [PATCH] Compare compact format of contact mechanism when updating Shopify customer Closes #14211 (grafted from ec97714ff8ca390738a1aad5c588b5e2e0bc39e4) --HG-- branch : 7.0 --- modules/web_shop_shopify/party.py | 4 +++- modules/web_shop_shopify/sale.py | 4 +++- .../tests/scenario_web_shop_shopify.rst | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/web_shop_shopify/party.py b/modules/web_shop_shopify/party.py index 128f3a6718..45c8384bb9 100644 --- a/modules/web_shop_shopify/party.py +++ b/modules/web_shop_shopify/party.py @@ -29,7 +29,9 @@ class Party(IdentifiersMixin, metaclass=PoolMeta): continue for contact_mechanism in contact_mechanisms: if (contact_mechanism.type in types - and contact_mechanism.value == value): + and (contact_mechanism.value_compact + == contact_mechanism.format_value_compact( + value, contact_mechanism.type))): break else: contact_mechanisms.append(ContactMechanism( diff --git a/modules/web_shop_shopify/sale.py b/modules/web_shop_shopify/sale.py index 698402cd50..1a58495586 100644 --- a/modules/web_shop_shopify/sale.py +++ b/modules/web_shop_shopify/sale.py @@ -110,7 +110,9 @@ class Sale(IdentifierMixin, metaclass=PoolMeta): if order.phone: for contact_mechanism in party.contact_mechanisms: if (contact_mechanism.type in {'phone', 'mobile'} - and contact_mechanism.value == order.phone): + and (contact_mechanism.value_compact + == contact_mechanism.format_value_compact( + order.phone, contact_mechanism.type))): break else: contact_mechanism = ContactMechanism( diff --git a/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst b/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst index 76d46e1c83..9c8645f0b9 100644 --- a/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst +++ b/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst @@ -441,6 +441,9 @@ Create an order on Shopify:: >>> customer.email = ( ... ''.join(random.choice(string.ascii_letters) for _ in range(10)) ... + '@example.com') + >>> customer_phone = '+32-495-555-' + ( + ... ''.join(random.choice(string.digits) for _ in range(3))) + >>> customer.phone = customer_phone >>> customer.addresses = [{ ... 'address1': "Street", ... 'city': "City", @@ -515,6 +518,14 @@ Run fetch order:: True >>> sale.state 'quotation' + >>> sale.party.name + 'Customer' + >>> bool(sale.party.email) + True + >>> sale.party.phone.replace(' ', '') == customer_phone.replace('-', '') + True + >>> len(sale.party.contact_mechanisms) + 2 Capture full amount:: @@ -537,6 +548,8 @@ Capture full amount:: 'processing' >>> len(sale.invoices) 0 + >>> len(sale.party.contact_mechanisms) + 2 Make a partial shipment::