[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
This commit is contained in:
Denis Ledoux
2015-12-10 16:58:15 +01:00
parent 893fbc0553
commit 4bebbfdcf5
2 changed files with 7 additions and 4 deletions
+6 -4
View File
@@ -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>
+1
View File
@@ -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