From e2cecc04546d5827c306e51a404bdbf98c33254e Mon Sep 17 00:00:00 2001 From: "Florimond Husquinet (fhu)" Date: Tue, 29 Sep 2020 15:48:15 +0000 Subject: [PATCH] [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#58885 X-original-commit: c1e52740d73cebe29e677c5247484aeb2c7d733f Signed-off-by: Xavier Morel (xmo) --- addons/mail_client_extension/controllers/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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: