From 7a03f9ce934814aaf7e8b57a0a16fff487b9e1b8 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 14 Feb 2017 12:14:11 +0100 Subject: [PATCH] [FIX] web, sale, account: company logo The notification mail template of a SO and an Invoice displays the logo of the company. However, the logo is always the logo of the superuser's company. When accessing the logo from an email client, the UID is not defined. Therefore, we fall back on the superuser, and display the logo of his company. We add the support of a `company` key in the kwargs, so we can force the company from which we retrieve the logo. Note that this key was used elsewhere, such as: addons/web/static/src/js/web_client.js opw-705420 --- addons/account/data/invoice_action_data.xml | 2 +- addons/sale/data/mail_template_data.xml | 2 +- addons/web/controllers/main.py | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/addons/account/data/invoice_action_data.xml b/addons/account/data/invoice_action_data.xml index cdbcec64e0c..4752247b988 100644 --- a/addons/account/data/invoice_action_data.xml +++ b/addons/account/data/invoice_action_data.xml @@ -79,7 +79,7 @@ from ${object.company_id.name}. - ${company.name} + ${company.name} diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index 72e948d375f..29da823b281 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -80,7 +80,7 @@ from ${object.company_id.name}. - ${company.name} + ${company.name} diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 496f234f7e0..cd7b93a549f 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1091,12 +1091,19 @@ class Binary(http.Controller): # create an empty registry registry = odoo.modules.registry.Registry(dbname) with registry.cursor() as cr: - cr.execute("""SELECT c.logo_web, c.write_date - FROM res_users u - LEFT JOIN res_company c - ON c.id = u.company_id - WHERE u.id = %s - """, (uid,)) + company = int(kw['company']) if kw and kw.get('company') else False + if company: + cr.execute("""SELECT logo_web, write_date + FROM res_company + WHERE id = %s + """, (company,)) + else: + cr.execute("""SELECT c.logo_web, c.write_date + FROM res_users u + LEFT JOIN res_company c + ON c.id = u.company_id + WHERE u.id = %s + """, (uid,)) row = cr.fetchone() if row and row[0]: image_base64 = str(row[0]).decode('base64')