Skip to content
Permalink
Browse files

[IMP] *: adding dbname in templates (wip)

  • Loading branch information...
kma-odoo committed May 15, 2019
1 parent 2385460 commit 0c5659c824dd8019197b162c07ac52e33e000d10
@@ -24,7 +24,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${object.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
<img src="/logo.png?company=${object.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
@@ -117,7 +117,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${object.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
<img src="/logo.png?company=${object.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
@@ -214,7 +214,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${object.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
<img src="/logo.png?company=${object.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
@@ -26,7 +26,7 @@

<div class="container">
<div class="o_logo">
<img class="img img-fluid d-block mx-auto" src="/web/binary/company_logo" alt="Logo"/>
<img class="img img-fluid d-block mx-auto" src="/web/binary/company_logo?dbname=${request.env.cr.dbname}" alt="Logo"/>
</div>

<div class="card">
@@ -12,6 +12,7 @@
<td align="center" valign="top" style="border-collapse: collapse; padding: 0">
% set user = ctx.get('user', user)
% set company = user.company_id
% set dbname = object.env.cr.dbname
% set data = object.compute_kpis(company, user)
% set tips = object.compute_tips(company, user)
% set kpi_actions = object.compute_kpis_actions(company, user)
@@ -23,7 +24,7 @@
<div style="color: #000000; font-size: 15px; margin-left:-22px;">${datetime.date.today().strftime('%B %d, %Y')}</div>
</td>
<td style="text-align: right; padding: 10px 40px">
<img style="padding: 0px; margin: 0px; height: auto; width: 80px;" src="/logo.png?company=${company.id}"/>
<img style="padding: 0px; margin: 0px; height: auto; width: 80px;" src="/logo.png?company=${company.id}&amp;dbname=${dbname}"/>
</td>
</tr>
<tr><td colspan="2" style="text-align: center;">
@@ -49,7 +49,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="${'/logo.png?company=%s' % object.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${'%s' % object.company_id.name}"/>
<img src="${'/logo.png?company=%s&amp;dbname=%s' % (object.company_id.id, object.env.cr.dbname)}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${'%s' % object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
@@ -246,7 +246,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="${'/logo.png?company=%s' % object.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${'%s' % object.company_id.name}"/>
<img src="${'/logo.png?company=%s&amp;dbname=%s' % (object.company_id.id, object.env.cr.dbname)}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${'%s' % object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
@@ -52,7 +52,7 @@
${object.badge_id.name}
</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${object.user_id.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.user_id.company_id.name}"/>
<img src="/logo.png?company=${object.user_id.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.user_id.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
@@ -73,7 +73,7 @@
<table style="width:600px;margin:5px auto;">
<tbody>
<tr>
<td><a href="/"><img src="/web/binary/company_logo" style="vertical-align:baseline;max-width:100px;" /></a></td>
<td><a href="/"><img src="/web/binary/company_logo?dbname=${object.env.cr.dbname}" style="vertical-align:baseline;max-width:100px;" /></a></td>
</tr>
</tbody>
</table>
@@ -35,7 +35,7 @@
<tr><td valign="middle">
<span style="font-size: 10px;">Lunch Order</span><br/>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${user.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % company.name"/>
<img src="/logo.png?company=${user.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % company.name"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
@@ -67,7 +67,10 @@
</t>
</td>
<td valign="center" align="right">
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: auto; max-width: 200px; max-height: 36px;" t-att-alt="'%s' % company.name"/>
Object: <t t-esc="object" /><br/>
Request: <t t-esc="request" /><br/>
Record: <t t-esc="record" />
<img t-att-src="'/logo.png?company=%s&amp;dbname=%s' % (company.id, request.env.cr.dbname)" style="padding: 0px; margin: 0px; height: auto; max-width: 200px; max-height: 36px;" t-att-alt="'%s' % company.name"/>
</td>
</tr><tr>
<td colspan="2" style="text-align:center;">
@@ -115,7 +118,7 @@
<t t-esc="message.record_name"/>
</span>
</td><td valign="middle" align="right">
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % company.name"/>
<img t-att-src="'/logo.png?company=%s&amp;dbname=%s' % (company.id, request.env.cr.dbname)" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % company.name"/>
</td></tr>
</table>
</td>
@@ -174,7 +177,7 @@
<t t-esc="message.record_name and message.record_name.replace('/','-') or ''"/>
</span>
</td><td valign="middle" align="right">
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
<img t-att-src="'/logo.png?company=%s&amp;dbname=%s' % (company.id, request.env.cr.dbname)" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
@@ -244,7 +247,7 @@
<t t-esc="message.record_name"/>
</span>
</td><td valign="middle" align="right">
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
<img t-att-src="'/logo.png?company=%s&amp;dbname=%s' % (company.id, request.env.cr.dbname)" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
@@ -460,12 +460,7 @@ def _sub_relative2absolute(match):
_sub_relative2absolute.base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
return match.group(1) + urls.url_join(_sub_relative2absolute.base_url, match.group(2))

def _sub_add_dbname(match):
# adding database name to logo url
return match.group(1) + match.group(2) + ("&dbname=" if '?' in match.group(2) else "?dbname=") + self.env.cr.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)
@@ -121,7 +121,7 @@
<header>
<div><title>Odoo</title></div>
<div class="text-center">
<img t-attf-src="/web/binary/company_logo"/>
<img t-attf-src="/web/binary/company_logo?dbname=#{request.env.cr.dbname}"/>
</div>
</header>
<div id="wrap" class="oe_structure oe_empty"/>
@@ -29,7 +29,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="${'/logo.png?company=%s' % object.company_id.id}" style="padding: 0px; margin: 0px; height: 48px;" alt="${object.company_id.name}"/>
<img src="${'/logo.png?company=%s&amp;dbname=%s' % (object.company_id.id, object.env.cr.dbname)}" style="padding: 0px; margin: 0px; height: 48px;" alt="${object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
@@ -29,7 +29,7 @@
${object.name}
</span>
</td><td valign="middle" align="right">
<img src="${'/logo.png?company=%s' % object.company_id.id}" style="padding: 0px; margin: 0px; height: 48px;" alt="${object.company_id.name}"/>
<img src="${'/logo.png?company=%s&amp;dbname=%s' % (object.company_id.id, object.env.cr.dbname)}" style="padding: 0px; margin: 0px; height: 48px;" alt="${object.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
@@ -21,7 +21,7 @@
${object.user_id.name}
</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${object.user_id.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.user_id.company_id.name}"/>
<img src="/logo.png?company=${object.user_id.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${object.user_id.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
@@ -28,7 +28,7 @@
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="container">
<a href="/" class="navbar-brand logo">
<img t-att-src="'/logo.png?company=%s' % res_company.id" t-att-alt="'Logo of %s' % res_company.name" t-att-title="res_company.name"/>
<img t-att-src="'/logo.png?company=%s&amp;dbname=%s' % (res_company.id, request.env.cr.dbname)" t-att-alt="'Logo of %s' % res_company.name" t-att-title="res_company.name"/>
</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#top_menu_collapse">
<span class="navbar-toggler-icon"/>
@@ -51,7 +51,7 @@
<tbody>
<tr><td>
<!-- We use the logo of the company that created the survey (to handle multi company cases) -->
<a href="/"><img src="/logo.png?company=${object.survey_id.create_uid.company_id.id}" style="vertical-align:baseline;max-width:100px;" /></a>
<a href="/"><img src="/logo.png?company=${object.survey_id.create_uid.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="vertical-align:baseline;max-width:100px;" /></a>
</td><td style="text-align:right;vertical-align:middle;">
Certification: ${object.survey_id.display_name}
</td></tr>
@@ -148,7 +148,7 @@
<header>
<div><title>Odoo</title></div>
<div class="text-center">
<img t-attf-src="/web/binary/company_logo" alt="Logo"/>
<img t-attf-src="/web/binary/company_logo?dbname=#{request.env.cr.dbname}" alt="Logo"/>
</div>
</header>
<div id="wrap" class="oe_structure oe_empty"/>
@@ -141,7 +141,7 @@
</div>

<div class="input-group align-items-center ml-2">
<input type="text" class="form-control o_we_url_input" name="url" t-attf-placeholder="https://www.odoo.com/#{isDocument ? 'mydocument' : 'logo.png'}"/>
<input type="text" class="form-control o_we_url_input" name="url" t-attf-placeholder="https://www.odoo.com/#{isDocument ? 'mydocument' : 'logo.png?dbname=' + request.env.cr.dbname}"/>
<div class="input-group-append align-items-center">
<button type="button" class="btn btn-secondary o_upload_media_url_button" disabled="disabled">
<t t-if="isDocument">Add document</t>
@@ -30,7 +30,7 @@
<tr><td valign="middle">
<span style="font-size: 10px;">Your leads</span><br/>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${user.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % company.name"/>
<img src="/logo.png?company=${user.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % company.name"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
@@ -18,7 +18,7 @@
<span style="font-size: 10px;">Your Channel</span><br/>
<span style="font-size: 20px; font-weight: bold;">${object.name}</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${user.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}"/>
<img src="/logo.png?company=${user.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
@@ -105,7 +105,7 @@
<span style="font-size: 10px;">Your Channel</span><br/>
<span style="font-size: 20px; font-weight: bold;">${object.name}</span>
</td><td valign="middle" align="right">
<img src="/logo.png?company=${user.company_id.id}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}"/>
<img src="/logo.png?company=${user.company_id.id}&amp;dbname=${object.env.cr.dbname}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}"/>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:16px 0px 16px 0px;"/>
Oops, something went wrong.

0 comments on commit 0c5659c

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