Skip to content

Commit c1e5274

Browse files
committed
[IMP] mail_client_extension: download the logo from the IAP
When creating a new company, it now downloads the logo from the url retrieved from the IAP. closes odoo#58851 Signed-off-by: Xavier Morel (xmo) <[email protected]>
1 parent 4344d50 commit c1e5274

File tree

1 file changed

+11
-0
lines changed
  • addons/mail_client_extension/controllers

1 file changed

+11
-0
lines changed

addons/mail_client_extension/controllers/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import logging
88
import odoo
9+
import requests
910
import werkzeug
1011

1112
import odoo.addons.iap.tools.iap_tools
@@ -172,6 +173,16 @@ def _create_company_from_iap(self, domain):
172173
'website': iap_data.get("domain"),
173174
'email': emails[0] if emails else None
174175
}
176+
177+
logo_url = iap_data.get('logo')
178+
if logo_url:
179+
try:
180+
response = requests.get(logo_url, timeout=2)
181+
if response.ok:
182+
new_company_info['image_1920'] = base64.b64encode(response.content)
183+
except Exception as e:
184+
_logger.warning('Download of image for new company %r failed, error %r' % (new_company_info.name, e))
185+
175186
if iap_data.get('country_code'):
176187
country = request.env['res.country'].search([('code', '=', iap_data['country_code'].upper())])
177188
if country:

0 commit comments

Comments
 (0)