Files
odoo_source/addons/project/data/mail_template_data.xml
T
Nicolas Bayet 4813f42997 [IMP] mail,*: replace jinja with qweb
Jinja as a templating engine was problematic in differents respect:
- introduce external dependency to Odoo (less controll)
- add another templating mechanism in the stack
- specific feature in qweb cannot be reused
- difficulty in rendering easily editable templates
- more knowledge required with no betterment

By replacing jinja with qweb we can now build tools to edit a qweb
that will work with the previously jinja encoded document
(essentially `mail.template` records).

There is a catch however. Some email fields (eg. email_to) used jinja
syntax for rendering dynamic variables (ie. ${object.something} and
${object.something_that_should_not_be_escaped | safe}).

We still want user to use dynamic variables for some char fields (eg.
subject, from, to, ...). We made a new rendering engine called
"inline_template" that will render an expression enclosed by `{{` and
`}}`.

To be able to edit the templates from the backend interface, a
plugin to the Odoo editor has been made for seamlessly edit the
document.

This qweb plugin includes:
- make dynamic variables (eg. `<t t-out="variable"/>`) not editable
  (for preventing the user to shoot himself in the foot)
- group and hide related logical branching (ie. t-if, t-elif, and t-else)
  in order to see only one at once
- a floating select input to switch visibility of a particular logical
  branching

Task-27033

X-original-commit: odoo/odoo@68182baff4
Part-of: odoo/odoo#77377
2021-09-28 23:42:54 +00:00

102 lines
5.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Sample stage-related template -->
<record id="mail_template_data_project_task" model="mail.template">
<field name="name">Task: Reception Acknowledgment</field>
<field name="model_id" ref="project.model_project_task"/>
<field name="subject">Reception of {{ object.name }}</field>
<field name="use_default_to" eval="True"/>
<field name="body_html" type="html">
<div>
Dear <t t-out="object.partner_id.name or 'customer'">Brandon Freeman</t>,<br/>
Thank you for your enquiry.<br />
If you have any questions, please let us know.
<br/><br/>
Thank you,
<t t-if="user.signature">
<br />
<t t-out="user.signature or ''">--<br/>Mitchell Admin</t>
</t>
</div>
</field>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="auto_delete" eval="True"/>
</record>
<!-- Mail sent to request a rating for a task -->
<record id="rating_project_request_email_template" model="mail.template">
<field name="name">Task: Rating Request</field>
<field name="model_id" ref="project.model_project_task"/>
<field name="subject">{{ object.project_id.company_id.name }}: Satisfaction Survey</field>
<field name="email_from">{{ (object.rating_get_rated_partner_id().email_formatted if object.rating_get_rated_partner_id() else user.email_formatted) }}</field>
<field name="partner_to" >{{ object.rating_get_partner_id().id }}</field>
<field name="body_html" type="html">
<div>
<t t-set="access_token" t-value="object.rating_get_access_token()"/>
<t t-set="partner" t-value="object.rating_get_partner_id()"/>
<table border="0" cellpadding="0" cellspacing="0" width="590" style="width:100%; margin:0px auto;">
<tbody>
<tr><td valign="top" style="font-size: 13px;">
<t t-if="partner.name">
Hello <t t-out="partner.name or ''">Brandon Freeman</t>,<br/><br/>
</t>
<t t-else="">
Hello,<br/><br/>
</t>
Please take a moment to rate our services related to the task "<strong t-out="object.name or ''">Planning and budget</strong>"
<t t-if="object.rating_get_rated_partner_id().name">
assigned to <strong t-out="object.rating_get_rated_partner_id().name or ''">Mitchell Admin</strong>.<br/>
</t>
<t t-else="">
.<br/>
</t>
</td></tr>
<tr><td style="text-align: center;">
<table border="0" cellpadding="0" cellspacing="0" width="590" summary="o_mail_notification" style="width:100%; margin: 32px 0px 32px 0px;">
<tr><td style="font-size: 13px;">
<strong>Tell us how you feel about our service</strong><br/>
<span style="text-color: #888888">(click on one of these smileys)</span>
</td></tr>
<tr><td style="font-size: 13px;">
<table style="width:100%;text-align:center;margin-top:2rem;">
<tr>
<td>
<a t-attf-href="/rate/{{ access_token }}/5">
<img alt="Satisfied" src="/rating/static/src/img/rating_5.png" title="Satisfied"/>
</a>
</td>
<td>
<a t-attf-href="/rate/{{ access_token }}/3">
<img alt="Okay" src="/rating/static/src/img/rating_3.png" title="Okay"/>
</a>
</td>
<td>
<a t-attf-href="/rate/{{ access_token }}/1">
<img alt="Dissatisfied" src="/rating/static/src/img/rating_1.png" title="Dissatisfied"/>
</a>
</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>
<tr><td valign="top" style="font-size: 13px;">
We appreciate your feedback. It helps us to improve continuously.
<t t-if="object.project_id.rating_status == 'stage'">
<br/><span style="margin: 0px 0px 0px 0px; font-size: 12px; opacity: 0.5; color: #454748;">This customer survey has been sent because your task has been moved to the stage <b t-out="object.stage_id.name or ''">In progress</b></span>
</t>
<t t-if="object.project_id.rating_status == 'periodic'">
<br/><span style="margin: 0px 0px 0px 0px; font-size: 12px; opacity: 0.5; color: #454748;">This customer survey is sent <b t-out="object.project_id.rating_status_period or ''">Weekly</b> as long as the task is in the <b t-out="object.stage_id.name or ''">In progress</b> stage.</span>
</t>
</td></tr>
</tbody>
</table>
</div>
</field>
<field name="lang">{{ object.rating_get_partner_id().lang }}</field>
<field name="auto_delete" eval="True"/>
</record>
</data>
</odoo>