diff --git a/modules/web_shop_shopify/CHANGELOG b/modules/web_shop_shopify/CHANGELOG index e7c75c5f04..e2ea2ffa0a 100644 --- a/modules/web_shop_shopify/CHANGELOG +++ b/modules/web_shop_shopify/CHANGELOG @@ -1,3 +1,4 @@ +* Set the language to party * Add admin URL to identifiers * Set compare-at price using non-sale price * Add support for product kit diff --git a/modules/web_shop_shopify/party.py b/modules/web_shop_shopify/party.py index 68ad87310a..6084409411 100644 --- a/modules/web_shop_shopify/party.py +++ b/modules/web_shop_shopify/party.py @@ -22,18 +22,25 @@ class Party(IdentifiersMixin, metaclass=PoolMeta): 'displayName': None, 'email': None, 'phone': None, + 'locale': None, } @classmethod def get_from_shopify(cls, shop, customer): pool = Pool() ContactMechanism = pool.get('party.contact_mechanism') + Lang = pool.get('ir.lang') party = cls.search_shopify_identifier( shop, gid2id(customer['id'])) if not party: party = cls() setattr_changed(party, 'name', remove_forbidden_chars( customer['displayName'])) + if customer['locale']: + lang = Lang.get(customer['locale']) + else: + lang = None + setattr_changed(party, 'lang', lang) contact_mechanisms = list(getattr(party, 'contact_mechanisms', [])) for types, value in [ (['email'], customer['email']), 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 02723a51db..69505a6bf7 100644 --- a/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst +++ b/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst @@ -476,6 +476,7 @@ Create an order on Shopify:: ... random.choice(string.ascii_letters) for _ in range(10)) ... + '@example.com'), ... 'phone': customer_phone, + ... 'locale': 'en-CA', ... }) >>> order = tools.create_order({ @@ -579,6 +580,8 @@ Run fetch order:: 'quotation' >>> sale.party.name 'Customer' + >>> sale.party.lang.code + 'en' >>> assertTrue(sale.party.email) >>> assertEqual(sale.party.phone.replace(' ', ''), customer_phone.replace('-', '')) >>> address, = sale.party.addresses