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
136 lines
6.5 KiB
XML
136 lines
6.5 KiB
XML
<?xml version="1.0" ?>
|
|
<odoo>
|
|
|
|
<!-- Mail template are declared in a NOUPDATE block
|
|
so users can freely customize/delete them -->
|
|
<data noupdate="1">
|
|
<!--Email template -->
|
|
<record id="email_template_edi_invoice" model="mail.template">
|
|
<field name="name">Invoice: Send by email</field>
|
|
<field name="model_id" ref="account.model_account_move"/>
|
|
<field name="email_from">{{ (object.invoice_user_id.email_formatted or user.email_formatted) }}</field>
|
|
<field name="partner_to">{{ object.partner_id.id }}</field>
|
|
<field name="subject">{{ object.company_id.name }} Invoice (Ref {{ object.name or 'n/a' }})</field>
|
|
<field name="body_html" type="html">
|
|
<div style="margin: 0px; padding: 0px;">
|
|
<p style="margin: 0px; padding: 0px; font-size: 13px;">
|
|
Dear
|
|
<t t-if="object.partner_id.parent_id">
|
|
<t t-out="object.partner_id.name or ''">Brandon Freeman</t> (<t t-out="object.partner_id.parent_id.name or ''">Azure Interior</t>),
|
|
</t>
|
|
<t t-else="">
|
|
<t t-out="object.partner_id.name or ''">Brandon Freeman</t>,
|
|
</t>
|
|
<br /><br />
|
|
Here is your
|
|
<t t-if="object.name">
|
|
invoice <strong t-out="object.name or ''">INV/2021/05/0005</strong>
|
|
</t>
|
|
<t t-else="">
|
|
invoice
|
|
</t>
|
|
<t t-if="object.invoice_origin">
|
|
(with reference: <t t-out="object.invoice_origin or ''">SUB003</t>)
|
|
</t>
|
|
amounting in <strong t-out="format_amount(object.amount_total, object.currency_id) or ''">$ 143,750.00</strong>
|
|
from <t t-out="object.company_id.name or ''">YourCompany</t>.
|
|
<t t-if="object.payment_state in ('paid', 'in_payment')">
|
|
This invoice is already paid.
|
|
</t>
|
|
<t t-else="">
|
|
Please remit payment at your earliest convenience.
|
|
<t t-if="object.payment_reference">
|
|
<br /><br />
|
|
Please use the following communication for your payment: <strong t-out="object.payment_reference or ''">INV/2021/05/0005</strong>.
|
|
</t>
|
|
</t>
|
|
<br /><br />
|
|
Do not hesitate to contact us if you have any questions.
|
|
<t t-if="object.invoice_user_id.signature">
|
|
<br />
|
|
<t t-out="object.invoice_user_id.signature or ''">--<br/>Mitchell Admin</t>
|
|
</t>
|
|
</p>
|
|
</div>
|
|
</field>
|
|
<field name="report_template" ref="account_invoices"/>
|
|
<field name="report_name">Invoice_{{ (object.name or '').replace('/','_') }}{{ object.state == 'draft' and '_draft' or '' }}</field>
|
|
<field name="lang">{{ object.partner_id.lang }}</field>
|
|
<field name="auto_delete" eval="True"/>
|
|
</record>
|
|
|
|
<record id="mail_template_data_payment_receipt" model="mail.template">
|
|
<field name="name">Payment Receipt: Send by email</field>
|
|
<field name="model_id" ref="account.model_account_payment"/>
|
|
<field name="subject">{{ object.company_id.name }} Payment Receipt (Ref {{ object.name or 'n/a' }})</field>
|
|
<field name="partner_to">{{ object.partner_id.id }}</field>
|
|
<field name="body_html" type="html">
|
|
<div style="margin: 0px; padding: 0px;">
|
|
<p style="margin: 0px; padding: 0px; font-size: 13px;">
|
|
Dear <t t-out="object.partner_id.name or ''">Azure Interior</t><br/><br/>
|
|
Thank you for your payment.
|
|
Here is your payment receipt <strong t-out="(object.name or '').replace('/','-') or ''">BNK1-2021-05-0002</strong> amounting
|
|
to <strong t-out="format_amount(object.amount, object.currency_id) or ''">$ 10.00</strong> from <t t-out="object.company_id.name or ''">YourCompany</t>.
|
|
<br /><br />
|
|
Do not hesitate to contact us if you have any questions.
|
|
<br/><br/>
|
|
Best regards,
|
|
<t t-if="user.signature">
|
|
<br/>
|
|
<t t-out="user.signature or ''">--<br/>Mitchell Admin</t>
|
|
</t>
|
|
</p>
|
|
</div>
|
|
</field>
|
|
<field name="report_template" ref="account.action_report_payment_receipt"/>
|
|
<field name="report_name">{{ (object.name or '').replace('/','-') }}</field>
|
|
<field name="lang">{{ object.partner_id.lang }}</field>
|
|
<field name="auto_delete" eval="True"/>
|
|
</record>
|
|
<!-- Credit note template -->
|
|
<record id="email_template_edi_credit_note" model="mail.template">
|
|
<field name="name">Credit note: Send by email</field>
|
|
<field name="model_id" ref="account.model_account_move"/>
|
|
<field name="email_from">{{ (object.invoice_user_id.email_formatted or user.email_formatted) }}</field>
|
|
<field name="partner_to">{{ object.partner_id.id }}</field>
|
|
<field name="subject">{{ object.company_id.name }} Credit Note (Ref {{ object.name or 'n/a' }})</field>
|
|
<field name="body_html" type="html">
|
|
<div style="margin: 0px; padding: 0px;">
|
|
<p style="margin: 0px; padding: 0px; font-size: 13px;">
|
|
Dear
|
|
<t t-if="object.partner_id.parent_id">
|
|
<t t-out="object.partner_id.name or ''">Brandon Freeman</t> (<t t-out="object.partner_id.parent_id.name or ''">Azure Interior</t>),
|
|
</t>
|
|
<t t-else="">
|
|
<t t-out="object.partner_id.name or ''">Brandon Freeman</t>,
|
|
</t>
|
|
<br /><br />
|
|
Here is your
|
|
<t t-if="object.name">
|
|
credit note <strong t-out="object.name or ''">RINV/2021/05/0001</strong>
|
|
</t>
|
|
<t t-else="">
|
|
credit note
|
|
</t>
|
|
<t t-if="object.invoice_origin">
|
|
(with reference: <t t-out="object.invoice_origin or ''">SUB003</t>)
|
|
</t>
|
|
amounting in <strong t-out="format_amount(object.amount_total, object.currency_id) or ''">$ 143,750.00</strong>
|
|
from <t t-out="object.company_id.name or ''">YourCompany</t>.
|
|
<br /><br />
|
|
Do not hesitate to contact us if you have any questions.
|
|
<t t-if="object.invoice_user_id.signature">
|
|
<br />
|
|
<t t-out="object.invoice_user_id.signature or ''">--<br/>Mitchell Admin</t>
|
|
</t>
|
|
</p>
|
|
</div>
|
|
</field>
|
|
<field name="report_template" ref="account_invoices"/>
|
|
<field name="report_name">Credit_note_{{ (object.name or '').replace('/','_') }}{{ object.state == 'draft' and '_draft' or '' }}</field>
|
|
<field name="lang">{{ object.partner_id.lang }}</field>
|
|
<field name="auto_delete" eval="True"/>
|
|
</record>
|
|
</data>
|
|
</odoo>
|