Skip to content
Browse files

[IMP] mail: adding database name in the url of company logo

In the mail templates, when the logo of the company is needed, by default, we use the route <domain_name>/logo.

In some cases the system does not manage to "guess" which DB or company to use and thus gives the default Odoo logo which can be problematic.

In this commit, we're adding database name as a parameter in logo url to overcome this issue.

Related Task ID: 1889370
  • Loading branch information...
kma-odoo authored and mba-odoo committed Mar 11, 2019
1 parent 7c68d2a commit 8990642049ad20101b97a0e1c04501ae4a1e7dc0
Showing with 5 additions and 0 deletions.
  1. +5 −0 addons/mail/models/
@@ -460,7 +460,12 @@ def _sub_relative2absolute(match):
_sub_relative2absolute.base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
return + urls.url_join(_sub_relative2absolute.base_url,

def _sub_add_dbname(match):
# adding database name to logo url
return + + ("&dbname=" if '?' in else "?dbname=") +

_sub_relative2absolute.base_url = base_url
html = re.sub(r"""(<img(?=\s)[^>]*\ssrc=")(/(web/binary/company_logo|logo|logo.png)(?!.*dbname)[^\"]+)""", _sub_add_dbname, html)
html = re.sub(r"""(<img(?=\s)[^>]*\ssrc=")(/[^/][^"]+)""", _sub_relative2absolute, html)
html = re.sub(r"""(<a(?=\s)[^>]*\shref=")(/[^/][^"]+)""", _sub_relative2absolute, html)
html = re.sub(r"""(<[^>]+\bstyle="[^"]+\burl\('?)(/[^/'][^'")]+)""", _sub_relative2absolute, html)

0 comments on commit 8990642

Please sign in to comment.
You can’t perform that action at this time.