summaryrefslogtreecommitdiff
path: root/addons/mail/data/mail_data.xml
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-01-12 11:34:30 +0100
committerThibault Delavallée <tde@odoo.com>2018-01-29 16:48:23 +0100
commit0f301bec25dd6d76fd6ac23275a82e0a32886bbc (patch)
treed9ef2ec0d5235a87dd05c96a0cd30897a3226a20 /addons/mail/data/mail_data.xml
parentd1ec600c432b0f47a40e6655a1e462213c4ad5a1 (diff)
[REF] mail: move email notification templates to QWeb
In this commit we change notification templates used to render notification emails from jinja-based mail.template to pure QWeb templates. There are several reasons to do so * those are not real mail.template records. Indeed they cannot be used outside of the notification process as some values are computed and not available on the mail.message record used to render the template; * we do not really need other fields than body. Indeed fields like subject, email_from or email_to are computed from the notification process; * we do not want people to update the mail.template without knowing the consequences, especially for fields like recipients that may broke the mail gateway; * using the html editor easily break the mail.template as it is very custom and very to break without really realizing it. It also simplifies template management as it lessens number of mail template people have in their list view of mail.template. It avoids mixing technical and functional templates. We move to QWeb templates as those are not too hard to customize and allow to perform body rendering which is what we really need when notifying people of a new message. This commit does not change the functional purpose and layout of the templates. Behavior should be the same before and after this commit.
Diffstat (limited to 'addons/mail/data/mail_data.xml')
-rw-r--r--addons/mail/data/mail_data.xml94
1 files changed, 36 insertions, 58 deletions
diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml
index c30ba66b37b..998a482de60 100644
--- a/addons/mail/data/mail_data.xml
+++ b/addons/mail/data/mail_data.xml
@@ -64,87 +64,65 @@
</data>
<data>
- <!--Default Notification Email template -->
- <record id="mail_template_data_notification_email_default" model="mail.template">
- <field name="name">Notification Email</field>
- <field name="subject">${object.subject or (object.record_name and 'Re: %s' % object.record_name) or (object.parent_id and object.parent_id.subject and 'Re: %s' % object.parent_id.subject) or (object.parent_id and object.parent_id.record_name and 'Re: %s' % object.parent_id.record_name)}</field>
- <field name="model_id" ref="mail.model_mail_message"/>
- <field name="auto_delete" eval="True"/>
- <field name="body_html" type="xml">
+ <template id="message_notification_email">
<div>
-% set company = ctx.get('company', user.company_id)
-% if ctx.get('has_button_access'):
-<div itemscope="itemscope" itemtype="http://schema.org/EmailMessage">
+<div t-if="has_button_access" itemscope="itemscope" itemtype="http://schema.org/EmailMessage">
<div itemprop="potentialAction" itemscope="itemscope" itemtype="http://schema.org/ViewAction">
<link itemprop="target" href="${ctx['button_access']['url']}"/>
<link itemprop="url" href="${ctx['button_access']['url']}"/>
<meta itemprop="name" content="View ${ctx['model_name']}"/>
</div>
</div>
-% endif
-% if not ctx['is_discussion'] or not len(ctx['actions']) == 0 or ctx.get('has_button_access'):
-<div summary="o_mail_notification" style="padding: 0px; width:600px;">
-<table cellspacing="0" cellpadding="0" border="0" style="width: 600px; margin-top: 5px;">
-<tbody><tr>
+<div t-if="has_button_access or len(actions) &gt; 0 or is_notification"
+ summary="o_mail_notification" style="padding: 0px; width:600px;">
+ <table cellspacing="0" cellpadding="0" border="0" style="width: 600px; margin-top: 5px;">
+ <tbody><tr>
<td valign="center">
- % if ctx.get('has_button_access'):
- <a href="${ctx['button_access']['url']}" style="padding: 8px 12px; font-size: 12px; color: #FFFFFF; text-decoration: none !important; font-weight: 400; background-color: #875A7B; border: 0px solid #875A7B; border-radius:3px">${ctx['button_access']['title']}</a>
- % endif
-
- % if ctx.get('actions'):
- % for action in ctx['actions']:
- |
- <a href="${action['url']}" style="color: #875A7B; text-decoration:none !important;">${action['title']}</a>
- % endfor
- % endif
+ <a t-if="has_button_access"
+ t-att-href="button_access['url']"
+ style="padding: 8px 12px; font-size: 12px; color: #FFFFFF; text-decoration: none !important; font-weight: 400; background-color: #875A7B; border: 0px solid #875A7B; border-radius:3px">
+ <t t-esc="button_access['title']"/>
+ </a>
+ <t t-if="actions">
+ <t t-foreach="actions" t-as="action">
+ |
+ <a t-att-href="action['url']" style="color: #875A7B; text-decoration:none !important;">
+ <t t-esc="action['title']"/>
+ </a>
+ </t>
+ </t>
</td>
<td valign="center" align="right">
- <img src="/logo.png?company=${company.id}" style="padding: 0px; margin: 0px; height: auto; max-width: 80px; max-height: 40px;" alt="${company.name}"/>
+ <img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: auto; max-width: 80px; max-height: 40px;" t-att-alt="'%s' % company.name"/>
</td>
-</tr>
-<tr>
+ </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:10px 0;"/>
- % if ctx.get('subtype') and ctx.get('subtype').internal:
- <p style="background-color: #f2dede; padding: 5px; margin-bottom: 16px;">
+ <p t-if="subtype.internal" style="background-color: #f2dede; padding: 5px; margin-bottom: 16px;">
<strong>Internal communication</strong>: Replying will post an internal note. Followers won't receive any email notification.
</p>
- % endif
</td>
-</tr>
-</tbody></table>
-</div>
-% endif
-<div>
- ${object.body | safe}
+ </tr></tbody>
+ </table>
</div>
-% if ctx.get('tracking'):
- <ul>
- % for tracking in ctx['tracking']
- <li>${tracking[0]} : ${tracking[1]} -&gt; ${tracking[2]}</li>
- % endfor
- </ul>
-% endif
-
-% if ctx.get('signature'):
- ${ctx['signature'] | safe}
-% endif
-<br/>
+<div t-raw="message.body"/>
+<ul t-if="tracking_values">
+ <t t-foreach="tracking_values" t-as="tracking">
+ <li><t t-esc="tracking[0]"/>: <t t-esc="tracking[1]"/> -&gt; <t t-esc="tracking[2]"/></li>
+ </t>
+</ul>
+<div t-if="signature" t-raw="signature"/>
<p style="color: #555555;">
Sent by
- % if ctx.get('website_url'):
- <a href="${ctx['website_url']}" style="text-decoration:none; color: #875A7B;">
- % endif
- ${ctx.get('company_name')}
- % if ctx.get('website_url'):
+ <a t-if="website_url" t-att-href="website_url" style="text-decoration:none; color: #875A7B;">
+ <span t-esc="company_name"/>
</a>
- % endif
+ <span t-if="not website_url" t-esc="company_name"/>
using
<a target="_blank" href="https://www.odoo.com" style="text-decoration:none; color: #875A7B;">Odoo</a>.
</p>
-</div></field>
- </record>
-
+</div>
+ </template>
</data>
</odoo>