From ff86912fe7d3fa10b68c28fb296f68387d1856a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 26 Sep 2021 23:07:57 +0200 Subject: [PATCH] Use contact_mechanism_get to get phone and email issue10752 review336931002 --- stock.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/stock.py b/stock.py index 980ab8f52b..9aa28cef9a 100644 --- a/stock.py +++ b/stock.py @@ -144,14 +144,8 @@ class CreateShippingSendcloud(Wizard): cm = UoM(ModelData.get_id('product', 'uom_centimeter')) party = shipment.shipping_to address = shipment.shipping_to_address - phone = email = None - for mechanism in party.contact_mechanisms: - if mechanism.type in {'phone', 'mobile'} and not phone: - phone = mechanism.value - if mechanism.type == 'email' and not email: - email = mechanism.value - if phone and email: - break + phone = party.contact_mechanism_get({'phone', 'mobile'}) + email = party.contact_mechanism_get('email') street_lines = (address.street or '').splitlines() parcel = { 'name': address.party_full_name, @@ -166,8 +160,8 @@ class CreateShippingSendcloud(Wizard): 'country_state': ( address.subdivision.code.split('-', 1)[1] if address.subdivision else None), - 'telephone': phone, - 'email': email, + 'telephone': phone.value if phone else None, + 'email': email.value if email else None, 'sender_address': credential.get_sender_address(shipment), 'external_reference': '/'.join([shipment.number, package.code]), 'quantity': 1,