Commit Graph
24 Commits
Author SHA1 Message Date
Yannick Tivisse fda7ec5f1f [FIX] mail: Fix truncated template field on mail.composer
TaskID: 3101400
2023-07-05 14:21:28 +02:00
Maryam Kia 896a69cc30 [IMP] mail: disable escape on composer wizard
task #2793003
- rename Cancel to Discard on composer wizard
- disable escape on composer wizard to prevent closing the composer accidentally

closes odoo/odoo#120427

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-06-21 00:13:46 +02:00
Victor Feyens 24ccf7d9b0 [CLN] *: useless type info for actions
The type fields of actions already defaults to
the model name in the base model definition.

Therefore, specifying `ir.actions.server`, `ir.actions.act_window`
& so on as type is useless (and adds noise since it's the same as
the action model).

closes odoo/odoo#114539

Related: odoo/enterprise#37855
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-03-08 17:33:37 +01:00
Thibault Delavallée 69209ae4bf [MOV] (mass_)mail(_ing): move 'model_is_thread' field to mail
This field will be used to remove low-level asserts using existence of
'message_post' on a given model instead of correctly checking the
inheritance on mail.thread.

This is going to increase a bit query counters but those queries should
be fast and have no real impact on performances.

Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#107356
2023-01-27 19:56:04 +01:00
Thibault Delavallée c298e1309d [REF] mail: allow to control composer exclusion list usage
Currently when using the composer excluded emails are computed when the target
model inherits from the blacklist mixin. This behavior can now be deactivated
through a new field 'use_exclusion_list', like what has been done in SMS
composer.

Task-3132710 (Mail: Configurable composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:42 +01:00
Thibault Delavallée 360d9ce201 [REF] mail: add 'force_send' field on composer to control email queue usage
Currently when using the composer to create a mass mailing emails are sent
directly, unless scheduled date is in the future.

With this commit it is now controllable through a field like what has been
done on SMS composer. Its default behavior is the same as before

  * posting on a monorecord: force send notification emails;
  * posting on multirecords: use the queue (force_send=False parameter given
    to message_post and propagated to _notify_thread);
  * mass mailing: use force send to send emails directly;

Usage of mail_notify_force_send context key is also removed when possible
as it is a standard parameter of posting API.

Task-3132710 (Mail: Configurable composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:41 +01:00
Thibault Delavallée 9140ce06c3 [REF] mail: better define 'keep log' fields of composer
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Change 'auto_delete_message' into 'auto_delete_keep_log' that has the inverse
meaning. Indeed it is unclear what 'auto_delete_message' really does. It is
used when automatically removing emails sent through mass mailing, to know
if message created through inherits are kept or not. Purpose of keeping them
is to have a log on the document. Deleting the message therefore removes the
log.

In this commit we change the meaning to something positive, keeping logs being
clearer when choosing which option to activate. Functional usage of the field
itself does not change with this commit.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:41 +01:00
Thibault Delavallée 629ba0c392 [REF] mail: replace 'is_log' on composer by posting a note
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Remove 'is_log' field on mail composer. Indeed its usage can be globally
replaced by using the 'note' subtype when posting. It is now better matching
the result of using the log a note mode of chatter.

Posting with a False subtype_id already automatically converts it into a
note subtype in 'message_post'. It is now done directly at composer level
to lessen magic and have more control on final output.

In case of outgoing emails subtype has no usage, as notification process is
not called. It is therefore forced to False when creating the mail records.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:40 +01:00
Thibault Delavallée fbcc1bf4c0 [IMP] mail: support 'scheduled_date' from template on composer
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Purpose of this task is to correctly support scheduled_date from template on
both comment and mass mode in the composer.

It is currently mainly supported at template level, when using a template
to directly send emails. In this commit we add a field on composer that
takes the value from the template, and propagate it to the mail or messages
created when validating it.

As most template fields it can contain inline template code to be rendered
dynamically on target records, hence using a char field. Its rendering
is done using template that calls _parse_scheduled_datetime. It allows
to have an UTC and timezone agnostic value.

SCHEDULED_DATE SUPPORT

When posting a comment, scheduled posts uses the 'mail.message.schedule'
mechanism that creates the message but send notifications later.

When sending a mailing, emails have a scheduled_date set. As the 'send'
method does not check for scheduled_date (only the cron queue) we have
to filter emails scheduled in the future before calling the 'send'
method.

Task-2993872 (Mail: Support scheduled date in all composer flows)

Part-of: odoo/odoo#99482
2023-01-17 20:58:40 +01:00
Thibault Delavallée 1a1acabd7b [REF] mail: cleanup mono/multi record composer behavior
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Support a real res_ids field on mail.compose.message model. Instead of relying
on active_ids from context, store it once for all at composer level and use
it in code. Active_ids usage is still done at default_get level, using it to
populate the field.

Improve usage of domain, renamed to res_domain to match other document related
fields naming. Add support of a res_domain_user_id field allowing to set the
user from which the domain should be evaluated.

Composer now runs on a list of IDs. Mass mail mode and comment mode are now
distinct from running on a singleton or on more records. Rendered or raw
mode is not triggered by

  * mass mailing mode: always display raw mode, whatever the number of records;
  * comment mode: display rendered mode when having a single record (like the
    previous comment mode). Display raw mode when having either no records
    either at least two records.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:39 +01:00
Thibault Delavallée 55bcb62131 [REM] mail: remove mass post option from mail composer
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Remove deprecated "mass_post" option from composer. It is either a comment
(using message_post) either a mass mail (creating emails). Mass post was
anyway nor used nor really supported. It will be replaced by supporting
having a comment on several IDs (batch comment mode, posting a message
on several records instead of being limited to one as currently).

This cleaning also allows to remove the 'notify' field that was an option
used for mass_post. All this should be supported through subtypes and
correct choice of post / mass mailing.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:39 +01:00
Thibault Delavallée 95859f6fb5 [REF] mail, various: cleanup usage of mail.composer.mixin
'email_from' fields are not necessary on 'sale.order.cancel' and 'survey.invite'
as anyway we always use the current user's email and field is not present in
form view. Override of default_get to raise about invalid email_from is not
necessary as anyway it raises when posting the message. Giving author_id to
message_post is sufficient as it computes email_from based on author when given.

Add 'render_model' in views, as it is part of the domain given to 'template_id'
field of composer mixin. When missing, also add 'lang' and 'template_id' that
come from the render mixin.

Use '_render_field' when possible instead of '_render_template' as its API
is simpler and uses field definition for rendering parameters.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:35 +01:00
Romeo Fragomeli 1f4be12781 [FIX] mail: the subject field is not correctly aligned
The field was not correctly aligned because the invisible rule was not
the same on the field and the sibling's DIV. So in some case, we can
have an empty DIV present with no label (e.g. when `is_log = false` and
`composition_mode = mass_mail`).

Note that now with grid, we need two filled columns otherwise we will
have a shift for the next following labels/fields, because grid will try
to fill the empty space.

Steps to reproduce:
* Open Helpdesk
* Select a Team
* Select the list view
* Check a row (line)
* Click on "Action" menu
* Click on "Send Email" => BUG

closes odoo/odoo#102941

X-original-commit: 52c8a8f4c16fe5765d64265f718164162f1cf172
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-10-10 18:09:06 +02:00
std-odoo 93fc52c8e1 [FIX] mail: allow a normal user to view the template body
Followup of odoo/odoo@1a3e713

Bug
===
If the user doesn't have the template editor, he cannot open the template
preview.

Technical
=========
The reason for that is because the web editor moves some CSS properties,
and so when the user tries to open the preview, an access error is raised.

Ideally, the template form view should not be editable if the access
rules do not allow it. But in _postprocess_tag_field, we only check
for access right because we don't have the record. So a user without
write access rules, but having write access right can edit the template
in the UI, and gets an error when saving.

Also, the web editor should not save the HTML value if no change are
made on the field (like all other text / char field).

To mitigate the issue in stable, we add a computed field that check the
access rules and make the body readonly if he can not edit the template.
So the web editor is not loaded, the CSS properties are not moved. Other
possible solutions are way to complex technically speaking (editor internals
to update in frontend, complex comparison of html blobs in backend, cache
usage making fields_view_get override not working in all cases, ... )

As the HTML body look weird in readonly mode, add the same border as the web
editor.

Task-2845877

X-original-commit: dcf3ab5fb41aa9ef6e59b2155bfd192e551b6476
Part-of: odoo/odoo#99256
2022-08-30 21:25:55 +02:00
Thibault Delavallée 6942fd3e28 [IMP] (test_)mail: add composer fields in view
Some fields in composer model allows to control generated messages or emails
values. However they are not available in the form view. In this commit we
add them in form view as invisible, as a first step towards cleaning the
composer code and usage.

Next step will be to cleanup composer code to remove the onchange based on
template and have real computed fields. Those will require fields to be
available in views so adding them is a necessary first step.

Some tests are added to see the usage and purpose of some fields. This helps
having a better code coverage.

Query counters update when using the Form tool

  * adding subtype_id: 2 queries
  * adding author_id: 1 query

Task-2816845
Prepares Task-2088884

Part-of: odoo/odoo#98287
2022-08-18 15:07:56 +02:00
Romeo Fragomeli 1fcd098af5 [REF] *: BS5: migration
Automated change made by a lot of RegEx to change all think that is
possible to automate.

https://getbootstrap.com/docs/5.1/migration

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:24 +02:00
Pierre-Yves Dufays fe2f4fee18 [IMP] base, mail, survey: improves slightly the UX
Improves UX by adding placeholders to clarify the purpose of some inputs and
changing some field layout to ease the edition (with the use of multi-lined
editor).

Details:
Some placeholders have been added:
- description field of survey.question
- default_note field of mail.activity.type
- summary of mail_activity_type_view_form

Some field layout have been turned into multi-lined editor:
- default_note field of mail.activity.type
- write a message in mass mail mode (email_compose_message_wizard_form)

added border for field help of edit action (class oe-bordered-editor)

Task-2766291

closes odoo/odoo#85046

Related: odoo/enterprise#24599
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-05-19 15:23:55 +02:00
Denis Ledoux dd2958a760 [FIX] mail: allow regular users to create mail non-dynamic templates
closes odoo/odoo#90896

X-original-commit: 96770827e42615c43b70bdae6529fb76ac66c518
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-05-09 17:05:43 +02:00
Sébastien Geelen (sge) 207a49275e [FIX] *: adapt some html fields in views
Some html field are not in their ideal style.
As the style for html fields is now dependent of
where you are in the xml view ( in group or not),
we have to adapt some views and flags some fields
to ensure they have the correct look.

This change is only be a visual enhancement
and should not prevent the function of said html fields
even if the views are not updated.

task-2637488

# Conflicts:
#	addons/mail/wizard/mail_compose_message_views.xml
#	addons/website_slides/views/slide_channel_views.xml

# Conflicts:
#	addons/sale/views/sale_views.xml

closes odoo/odoo#83792

Related: odoo/enterprise#23911
Signed-off-by: Antoine Guenet <age@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2022-02-02 09:03:44 +00:00
Krina Oza ff2ffb9e0d [IMP] web,sale_(project): improve keyboard navigation
The purpose of this commit is, to add keyboard shortcut
to multiple actions.

So in this commit, added keyboard shortcut to several actions
in project, sale_project, web_calendar and added smart action
in command palette on statusbar.

task-2655790

closes odoo/odoo#79805

Related: odoo/enterprise#22267
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-01-11 12:14:43 +00:00
Thibault Delavallée 3659546738 [IMP] mail, various: support email notification xmlid at model level in composer
RATIONALE

Currently we can specify email used for notification layouting through context
use in mail composer. It is then propagated to message_post, stored on
mail.message and used to encapsulate emails sent based on posted messages.

SPECIFICATIONS

Get rid of context usage (``custom_layout``) and use a real field on composer
model: ``email_layout_xmlid``. Use now a default value coming from context
(default_email_layout_xmlid) instead of custom_layout.

Support old context key in composer for backward compatibility, working like
a default value for the field itself.

Task-2621326 (Mail: add 'view' button in 'light notification template')
Task-2647302 (Mail: add layout field in composer)
UPG odoo/upgrade#2829

Part-of: odoo/odoo#76418
2021-11-10 09:58:09 +00:00
Julien Banken fbb9a25367 [IMP] mail: revamp the mail composer
On the CRM module, the user can send an email to all the contacts
associated to the leads matching some criteria by (1) displaying the
list view, (2) applying a search filter, (3) clicking on the "EMAIL"
button and (4) checking a checkbox on the mail composer to ask the
server to use the active search. To do the same thing, the user can
(1) display the list view, (2) apply a search filter, (3) select all
the records and (3) click on the "EMAIL" button.

To avoid redundancy and improve the usability of the composer, we will
remove the search domain passing from the mail composer. Note that it
will still be possible to pass a search domain programmatically.

To improve the guidance of the mail composer, we will add helper
messages, update the labels and move the options in a dedicated pane.
The wording of the buttons will also be updated dynamically based on
the selected options.

Example: When the user enters something in the `mass_mailing_name` field
to create a new mass mailing campaign from the new message, the label of
the "Send" button will be set to "Send Mass Mailing" which gives more
indication on what will happen when the user clicks on it.

task-2523036

Part-of: odoo/odoo#71413
2021-09-30 13:31:52 +00:00
std-odoo cc012a0864 [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>
2021-09-02 03:42:54 +00:00
Thibault Delavallée cb67c23888 [MOV] mail: reorder controllers and views
As mail grows and will continue to grow, ordering views and having right
files is important to understand module organization and content.

Split main.py controller file into two files, one for mail related controllers
(redirections) and one for discuss.

Rename files according to guidelines for wizards and views.

No functional change comes with this commit. This is only code move.

Task-2631873
PR odoo/odoo#75571
2021-08-25 13:12:11 +00:00