Skip to content

Commit e497fa0

Browse files
committed
[FIX] mail_client_extension: checks for empty list in iap data
Instead of not returning the key, the IAP returns an empty list when there is no phone number or no email. closes odoo#58840 Signed-off-by: Xavier Morel (xmo) <[email protected]>
1 parent 563eafc commit e497fa0

File tree

1 file changed

+4
-2
lines changed
  • addons/mail_client_extension/controllers

1 file changed

+4
-2
lines changed

addons/mail_client_extension/controllers/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,17 @@ def _create_company_from_iap(self, domain):
160160
if 'enrichment_info' in iap_data:
161161
return None, iap_data['enrichment_info']
162162

163+
phone_numbers = iap_data.get('phone_numbers')
164+
emails = iap_data.get('email')
163165
new_company_info = {
164166
'is_company': True,
165167
'name': iap_data.get("name"),
166168
'street': iap_data.get("street_name"),
167169
'city': iap_data.get("city"),
168170
'zip': iap_data.get("postal_code"),
169-
'phone': iap_data.get('phone_numbers', [''])[0],
171+
'phone': phone_numbers[0] if phone_numbers else None,
170172
'website': iap_data.get("domain"),
171-
'email': iap_data.get('email', [''])[0]
173+
'email': emails[0] if emails else None
172174
}
173175
if iap_data.get('country_code'):
174176
country = request.env['res.country'].search([('code', '=', iap_data['country_code'].upper())])

0 commit comments

Comments
 (0)