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
Purpose is to have all mail template into a mail_template_data.xml file
when possible. It eases maintenance and update when having to work globally
on template records.
Also update some ``body_html`` declarations still using ``xml`` instead of
``html``.
Task ID-2534550 (Template usage improvement)
Task ID-2477164 (Composer mixin)
Prepares Task ID-27033 (QWeb in templates)
COM PR odoo/odoo#70889
ENT PR odoo/enterprise#18352
Distinguish and display to the speaker which info is collected by the form
for internal use vs external dissemination. The contact details one wants to
share with the event manager (Private details : contact_phone, contact_email)
could indeed be different from the ones shared to attendees (partner_phone,
partner_email,...). The form in both back-end and front-end is made more
detailed, including more fields. Previously the form could have several
speakers, now only one.
Front-End
- Track proposal form changed, now includes tags, contact / speaker info...
- Track name and description are mandatory fields
- User can select (but not create) several track tags from those existing.
This allows categorizing the track in pre-defined categories with format
"tag category : tag name". It requires a select2 widget,
implemented in new file website_event_track_proposal_add_tag.js.
- New tickable section "contact me through different contact" not displayed
if the checkbox is not ticked. If the section is ticked, then the info set
there (contact_name, contact_phone, contact_email) will be added on a new
contact with id partner_id set on the track.
- In both cases (checkbox on/off), if the contact/partner email is the
same as logged user's, uses its partner on form. No contact creation needed.
- Improved / dynamic error display on form submission. If the form is valid,
it resets after submission.
- New widget in website_event_track_proposal.js:
- The partner_name is propagated on contact_name on input but editable.
- When the optional section is checked:
- The contact_name is made required.
- The user must at least enter a contact phone or an email. The email
is normalized but any phone format is accepted, since the choice of
country is not resolved (e.g. geoip not always relevant). Could be
improved with international phone number widget, see COM PR #34725
Back-end: following changes are done to ease contact creation and form completion
from back-end, as well as reaching the speaker from chatter
- On the form:
- If created on the fly from M2O (entering a name and using "create ..."),
the new partner will use default values contact_phone and contact_email.
- Once the contact is set (partner_id), contact_phone and contact_email
are set to readonly since they change according to the partner.
- When setting or changing the partner: this will fill all the form fields
with new available partner data to ease the flow, but only the empty ones
(this prevents losing previously entered information).
If partner is a company, company name is set to the name of partner.
- All fields are editable in the speaker section.
- Exception thrown if no contact mean available when supposed to.
- On the chatter, about contact creation and message subscription:
- From contact creation through suggested contacts.
- If the partner is set but is not in the followers, it is suggested
- If no partner is set, then there is at maximum one suggested contact
from track data: using contact_email if there is one, partner_email
otherwise. This priority serves main commit purpose. The user can
create and edit a corresponding contact if the address is not linked
to a partner. It will then be searched for and set on track.
Modifies tests in test_track_partner_sync. Before, partner fields on track
would be erased by customer's ones. Now, they are updated only if empty.
Contact fields are erased by customer's ones if set. tests changed accordingly.
Task ID - 2329406
COM PR odoo/odoo#60847
UPG PR odoo/upgrade#2346
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
PURPOSE
Clean organization of templates in odoo apps: mail.template records in data,
qweb templates (views) used directly in code, notably using post with view.
Purpose is to ease future improvements in posting based on templates.
SPECIFICATIONS
* move those templates in their own file to ease their discovering and
maintenance;
* put them into data (as those are not views even if it contains qweb)
* guidelines are now :
-> Qweb templates should be in data/mail_templates.xml;
-> mail.template records should be in data/mail_template_data.xml;
* put their declaration in no update when not done if template has no
technical code or complex dependency on underlying code;
* move found mail data (mail.message.subtype or mail.activity.type) records
in a mail_data file that should contain only "core" records linked to mail;
LINKS
Task ID-2375767
COM PR odoo/odoo#61814
ENT PR odoo/enterprise#14775
UPG PR odoo/upgrade#1936