Skip to content
Snippets Groups Projects
Commit 4bebbfdc authored by Denis Ledoux's avatar Denis Ledoux
Browse files

[FIX] mail: jinja2 code compatible with wysiwyg for notifications

When editing an email template with the wysiwyg,
the `<` and `>` operators are automatically converted
to `&lt;` and `&gt;`, even for the Jinja2 conditions,
therefore breaking these conditions, and the render
of the email templates.

We avoid to use these operators in the email
template, so users can customize the notification
email template without having an advanced
knowledge on how to edit an email template containing
Jinja2 code.

Besides, the line return at the end of the email template,
just after the `% endif`,
is done on purpose as well: the wysiwyg adds automatically,
at the time of this revision,
`<p></p>` at the end of the email template source, but
this cannot be added on the same line than `% endif`,
otherwise this is considered as Jinja2 code, and it's not.

opw-659113
parent 893fbc05
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,7 @@
% endif
% if not ctx.get('button_access') and not ctx.get('button_follow') and not ctx.get('button_unfollow') and ctx.get('model_name'):
<p style="padding: 5px 10px; font-size: 12px;"">
<p style="padding: 5px 10px; font-size: 12px;">
About <strong>${ctx['model_name']}
% if ctx.get('record_name'):
: ${ctx['record_name']}
......@@ -97,7 +97,7 @@
% if ctx.get('actions'):
% for action in ctx['actions']:
<a href="${action['url']}" style="text-decoration:none; color: #a24689;"><strong>${action['title']}</strong></a>
%if len(ctx['actions']) > 1 and loop.index < len(ctx['actions']):
%if cmp(len(ctx['actions']), 1) == 1 and cmp(len(ctx['actions']), loop.index) == 1:
|
% endif
% endfor
......@@ -113,6 +113,7 @@
<strong>using</strong>
<a href="www.odoo.com" style="text-decoration:none; color: #a24689;"><strong>Odoo</strong></a>
% endif
</p>
</td>
</tr>
</tbody></table>
......@@ -136,7 +137,7 @@
% if ctx.get('tracking'):
<ul>
% for tracking in ctx['tracking']
<li>${tracking[0]} : ${tracking[1]} -> ${tracking[2]}</li>
<li>${tracking[0]} : ${tracking[1]} -&gt; ${tracking[2]}</li>
% endfor
</ul>
% endif
......@@ -154,7 +155,8 @@
</tr></tbody>
</table>
</div>
% endif]]></field>
% endif
]]></field>
</record>
</data>
......
......@@ -77,6 +77,7 @@ try:
'reduce': reduce,
'map': map,
'round': round,
'cmp': cmp,
# dateutil.relativedelta is an old-style class and cannot be directly
# instanciated wihtin a jinja2 expression, so a lambda "proxy" is
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment