diff options
| author | Florimond Husquinet (fhu) <fhu@odoo.com> | 2020-09-29 15:48:15 +0000 |
|---|---|---|
| committer | Florimond Husquinet (fhu) <fhu@odoo.com> | 2020-09-30 07:21:39 +0000 |
| commit | c1e52740d73cebe29e677c5247484aeb2c7d733f (patch) | |
| tree | 697b829a23e88ea033a53c9441e9b2212e135120 /addons/mail_client_extension/controllers | |
| parent | 4344d50a74b04ffed7a7113e8af2b8ad6800693e (diff) | |
[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/odoo#58851
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/mail_client_extension/controllers')
| -rw-r--r-- | addons/mail_client_extension/controllers/main.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/addons/mail_client_extension/controllers/main.py b/addons/mail_client_extension/controllers/main.py index d435406d945..3360ff5e8f3 100644 --- a/addons/mail_client_extension/controllers/main.py +++ b/addons/mail_client_extension/controllers/main.py @@ -6,6 +6,7 @@ import hmac import json import logging import odoo +import requests import werkzeug import odoo.addons.iap.tools.iap_tools @@ -172,6 +173,16 @@ class MailClientExtensionController(http.Controller): 'website': iap_data.get("domain"), 'email': emails[0] if emails else None } + + logo_url = iap_data.get('logo') + if logo_url: + try: + response = requests.get(logo_url, timeout=2) + if response.ok: + new_company_info['image_1920'] = base64.b64encode(response.content) + except Exception as e: + _logger.warning('Download of image for new company %r failed, error %r' % (new_company_info.name, e)) + if iap_data.get('country_code'): country = request.env['res.country'].search([('code', '=', iap_data['country_code'].upper())]) if country: |
