[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
This commit is contained in:
@@ -79,7 +79,7 @@ from ${object.company_id.name}.
|
||||
</span>
|
||||
</td>
|
||||
<td valign="middle" align="right">
|
||||
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${company.name}">
|
||||
<img src="/logo.png?company=${company.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${company.name}">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -80,7 +80,7 @@ from ${object.company_id.name}.
|
||||
</span>
|
||||
</td>
|
||||
<td valign="middle" align="right">
|
||||
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${company.name}">
|
||||
<img src="/logo.png?company=${company.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${company.name}">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user