-
- Downloads
[IMP] mail, various: add email templates management levels
Purpose
=======
Purpose of this commit is to add a new group for the mail template designer.
Goal is to make roles clearer: managers edit templates, users use them. This
commit allow some designers / managers to make email template and to let
others users use those email templates.
Specifications
==============
When this feature is enabled in the Settings page, a new group is required to
modify email templates in a composer like wizard or to make dynamic content.
This allows to separate managers editing / composing templates from standard
users that use them.
If the current does not have this group, the email body will be in readonly
mode if he selected an email template. That way we force him to use the email
template that the manager made.
Technical
=========
New Group
---------
Only users in this group will be able to create / write email template or
to write Jinja code in the mail composer (including other fields like subject
in mailing).
By default, all internal users have this group. Mass mailing users also have
this group as writing mailings is about the same management level as writing
templates.
Mail Composer Mixin
-------------------
In comment mode, the template is rendered and then saved on the body field
so non-"Mail Template Editor" users can load email templates.
But in mass mode, the body of the template is saved and then rendered and
many things change the body (HTML sanitizer, web editor move inline CSS
properties, add / remove spaces...). So in this case, we can not know if
the user changed the body or not. That is why we put the body field in
readonly mode so, it is not modified by the web editor.
Jinja code detection
--------------------
To detect dynamic Jinja content, we compile the template, and we browse the
AST. If we do not have a single "Template Data" node, we assume that the
template is dynamic.
When we detect the template as static, we do not render it. That way we
avoid unnecessary rendering.
Code cleaning
-------------
Move Jinja import into tools so that it is outside of mail framework code.
Task-2187263
closes odoo/odoo#75840
Related: odoo/enterprise#20547
Signed-off-by:
Thibault Delavallee (tde) <tde@openerp.com>
Showing
- addons/digest/models/digest.py 1 addition, 1 deletionaddons/digest/models/digest.py
- addons/mail/__manifest__.py 1 addition, 0 deletionsaddons/mail/__manifest__.py
- addons/mail/data/mail_groups.xml 18 additions, 0 deletionsaddons/mail/data/mail_groups.xml
- addons/mail/models/ir_config_parameter.py 14 additions, 0 deletionsaddons/mail/models/ir_config_parameter.py
- addons/mail/models/mail_composer_mixin.py 47 additions, 3 deletionsaddons/mail/models/mail_composer_mixin.py
- addons/mail/models/mail_render_mixin.py 19 additions, 53 deletionsaddons/mail/models/mail_render_mixin.py
- addons/mail/models/mail_template.py 2 additions, 0 deletionsaddons/mail/models/mail_template.py
- addons/mail/models/res_config_settings.py 5 additions, 0 deletionsaddons/mail/models/res_config_settings.py
- addons/mail/security/ir.model.access.csv 2 additions, 1 deletionaddons/mail/security/ir.model.access.csv
- addons/mail/tests/__init__.py 1 addition, 0 deletionsaddons/mail/tests/__init__.py
- addons/mail/tests/common.py 3 additions, 1 deletionaddons/mail/tests/common.py
- addons/mail/tests/test_mail_render.py 74 additions, 4 deletionsaddons/mail/tests/test_mail_render.py
- addons/mail/tests/test_mail_template.py 65 additions, 0 deletionsaddons/mail/tests/test_mail_template.py
- addons/mail/views/res_config_settings_views.xml 12 additions, 0 deletionsaddons/mail/views/res_config_settings_views.xml
- addons/mail/wizard/mail_compose_message.py 8 additions, 0 deletionsaddons/mail/wizard/mail_compose_message.py
- addons/mail/wizard/mail_compose_message_views.xml 3 additions, 3 deletionsaddons/mail/wizard/mail_compose_message_views.xml
- addons/mass_mailing/security/mass_mailing_security.xml 4 additions, 0 deletionsaddons/mass_mailing/security/mass_mailing_security.xml
- addons/portal/__init__.py 1 addition, 1 deletionaddons/portal/__init__.py
- addons/sms/models/sms_template.py 2 additions, 0 deletionsaddons/sms/models/sms_template.py
- addons/sms/tests/test_sms_template.py 46 additions, 1 deletionaddons/sms/tests/test_sms_template.py
Loading
Please register or sign in to comment