Commit Graph
26 Commits
Author SHA1 Message Date
Julien Banken e4c583fcc8 [IMP] mail,sms: revamp the resend modals
The error messages of the resend modals can be partially hidden in the
table. The user can therefore have difficulty to understand what went
wrong when the server failed to send an email or an sms. To avoid that,
we will ensure that the error messages will be fully visible in the table.

To improve the interface, we will also update the label of a some fields
and we will automatically hide the 'Send & Close' buttons from the resend
modals when the user did not select at least one recipient from the list.

task-2523036

Part-of: odoo/odoo#71413
2021-09-30 13:31:53 +00:00
Thibault Delavallée c4dacc24fa [REF] mail, sms: simplify notification recipients structure
Now that recipients in notification process are always partners due to
simplification of MailFollower model we can safely simplify the structure
used to collect and propagate recipients information.

Before this task it was a dictionary with a list of partner related data and
a list of channel related data. It is now simply a list of partner related
data, leading to various code cleaning.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:22:20 +00:00
Thibault Delavallée 4cb1f56aba [REF] mail, sms, test_mail: remove now unused channel_id field on Py and JS follower models
RATIONALE

Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.

PURPOSE

Remove channel ability to follow records as it mainly adds noise without a lot
of added value. Simplify channel notification flow by using directly members
and not a delegation through a channel self-following trick. Remove followers
being channels and posting with added listeners being channels.

SPECIFICATIONS

As there is no way to add channel-based follower anymore we can remove all
fields and code supporting this feature. Notably we can remove ``channel_id``
field on ``mail.follower`` model as well all code using it, notably compute
methods.

In this commit we also make ``partner_id`` field required as now followers
are always partners. Email, name and active fields are now simple related
fields on the partner.

Code computing data about subscription is also updated and simplified. As
we do not have channels anymore but only partners all custom SQL queries
are now simplified.

JS models for Discuss are also cleaned. Following python change, JS models
are simplified to match the backend models. Channel_id is removed, partner_id
is now required, and various code is updated according to the simplified
model.

Side note: we could probably get rid of specific index on ``partner_id``
field. However we have to ensure we never search for followers without being
in a model / res_id context. This will be done in another cleaning step to
be sure performance are not broken.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:16:18 +00:00
Julien Castiaux db9bf62431 [REF] mail: Use Command helper for x2many
closes odoo/odoo#60965

Task: 2366606
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-11-30 10:16:09 +00:00
Victor Feyens fdb23e282b [IMP] *: wrong any() usage
Replace wrong usages of any(list|recordset), by any(generator)
to speed up computations, avoiding list creations and/or looping twice on a recordset
for nothing.

any([generator]) => any(generator)
any(filtered) => any(generator)

closes odoo/odoo#55768

Related: odoo/enterprise#12360
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-08-14 09:56:10 +00:00
Sébastien Theys dea52493b8 [IMP] mail, sms, snailmail, test_mail_full: adapt mail.notification
The purpose is to have more common code for failure and notifications, with less
override in `sms` and `snailmail`.

task-2176017

closes odoo/odoo#44170

Related: odoo/enterprise#9140
Related: odoo/upgrade#918
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-04-17 12:17:57 +00:00
Thibault Delavallée ce77c64e63 [FIX] mail: fix typo in additional
Task ID 2211781

closes odoo/odoo#47937

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-03-18 15:38:22 +00:00
Christophe Simonis 72d9167c3a [FIX] mail: add missing import
Oversight of previous forward-port.
2019-08-21 10:58:04 +02:00
Christophe Simonis 3faea8fbf8 [MERGE] forward port branch saas-12.4 up to f26de445e5 2019-08-21 10:10:11 +02:00
Christophe Simonis f26de445e5 [MERGE] forward port branch saas-12.3 up to 6f55fd65da 2019-08-20 12:17:04 +02:00
Martin Trigaux 496d2c30ad [FIX] account,iap,sale,mail,portal: translate error messages
The error were untranslatables

Courtesy of Moises Lopez

closes odoo/odoo#35573

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-08-08 13:56:25 +00:00
Xavier-Do 581a74143e [REF] mail: simplify notification code
Purpose of this commit is to clean notification process: calls, methods
API, method name, variable propagation.

Contains notably

  * simplify API of methods used to group recipients when sending notification
    emails;
  * improve and rename methods used in email notification process;
  * move some methods on model itself as non mail thread records could be
    mass-mailed and _notify_email_headers could be called on other records;

Related to task 1943901
Linked to PR #32404
2019-05-29 13:34:32 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Thibault Delavallée 488a5d5af5 [IMP] mail: prepare new SMS model by updating mail.notification
This commit prepares SMS refactoring by updating some mail models. Purpose
is to be able to store SMS notification information inside existing mail
flow and models.

Main changes

  * mail.notification: define a notification_type field to store the medium
    used to notify people. In mail two ways exist: inbox and email. It will
    ease introduction of SMS notification mechanism. This field replaces the
    is_email boolean field;
  * mail.notification: make res_partner_id field not required. This means
    notifications could be linked to something else than a partner. An SMS
    for example. For Inbox and email notifications partner is still required
    and a constraint is added accordingly;
  * mail.thread: let notification methods handle the creation and update of
    their notification instead of creating them in _notify_thread and tweaking
    them in sub notification methods;
  * mail.thread: clearly move inbox-style notification in its own method like
    notify by email;

Some lighter code changes

  * propagate message_type to notification recipient computation. It will
    allow for example to be more precise when computing a notification type
    depending on the message_type. For example, send a notification by SMS
    when the message_type is SMS;
  * ease inheritance of ``_notify_thread`` by returning computed recipients
    data. It will allow to work on it without having to re-compute it;
  * propagate kwargs from message_post and message_notify to notify methods.
    This allow to avoid depending on context and set explicit parameters.
    Drawback is that message_post and notify must separate kwargs used to
    create a message and those that are propagated to notification methods;
  * update various notification check to ensure they work on email
    notifications, notably the resend and cancel wizards;

One side effect of this commit is that notifications are created by the
relevant notification method. Previously all notifications were created
by writing on needaction_partner_ids fields then updated according to the
notification process. Notably there could be too much notification created
when sending emails due to _notify_customize_recipients not being correctly
synchronized with notification. This issue is now solved as only really
sent emails create notifications.

Migration tips

  * notification_type: notification.is_email and 'email' else 'inbox';
  * remove is_email;

Related to task 1922163
Linked to PR #33510
2019-07-12 14:54:11 +00:00
Thibault DelavalléeandPierre Rousseau 566244b47b [REF] mail, sms: perform some guidelining (file move) and rename SMS composer model
Purpose is to prepare future improvements in mail and SMS module. In this
commit we apply some guidelines on XML Ids and file naming.

In mail cancel wizard code is separated from the resend one as they have
nothing in common.

More importantly ``sms.send_sms`` model is renamed to ``sms.composer`` to
avoid underscores (which is really really bad, take a look at
ir.config_parameter) and have a meaningful name.

Related to task 1922163
Linked to PR #34516

Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-02 10:39:25 +00:00
Toufik Ben Jaa b49d5388ff [FIX] mail: crash on mail resend
- When resending a failed mail the code could crash.
  The issue is caused by the fact that calling `_get_recipient_data`
  with the parameter `pids` only, returns as the partners' groups the
  value `None`.

  The codes that uses the result of this method consider the groups as
  an iterable and crash when trying to iterate on a `NoneType`.

  OPW-1916498

closes odoo/odoo#29408
2018-12-11 08:32:12 +00:00
Adrian Torres 3f4f77fd9d [REF] *: adapt code to new related default behaviour
This commit adapts the business code to changes introduced by
the parent commit in order to keep the same behaviour as before.

All readonly=False fields will have to be checked afterwards to confirm
that the business case requires write access to the source field.
2018-09-27 12:10:23 +02:00
Christophe Simonis 68d36512ef [MERGE] forward port branch saas-11.4 up to d78f23df84 2018-09-07 20:20:45 +02:00
XavierDo 554414b90f [FIX] mail: fix use of resend wizard when user are in failure
The user right to edit partners was handled in order to set email fields as readonly
If a user is in the failed recipient, we need to check that the urrent user also has
right to write on users
2018-09-06 10:33:59 +02:00
Thibault Delavallée 689a496f1c [REF] mail: propagate recipient data through notification process
Purpose of this commit is to avoid browsing and prefetching data about
recipients when notifying a message to partners and channels. Mail message
_notify computes all necessary data in a single query. This commit allow
to re-use this data by propagating it through the call chain.

Addons inheriting from classification methods used when sending notification
emails are updated accordingly to the API and data update.

This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
2018-08-07 15:43:06 +02:00
Thibault Delavallée 89051058f4 [REF] mail: clean code related to notification email generation
This commit cleans code about sending email notification to recipients.
Purpose of this code is to prepare notification emails, group recipients
and finally send emails. In this commit we clean and optimize a bit by

 * propagating some additional parameter to simplify code, like record
   on which the notification process runs;
 * inlining some code currently located in sub-methods. It eases code
   understanding as there are less code jumps. As those methods are not
   inherited inlining them can be done;
 * simplifying a bit notification emails preparation and computation;

It allows to save a few query by avoiding to fetch and browse again some
data that were already computed.

This commit is linked to task ID 47934 and PR #24033. No functional change
should occur with this commit.
2018-08-07 15:43:06 +02:00
XavierDo c8d283a592 [FIX]: mail: storing add_sign on mail message
Only the add_sign from notif_values is usefull for a resend. We can consider
that a mail on resend can be delete in every case, and we can find the
model_description from model since a resend can only be performed on
message linked to a model.

The other notif_values are now parameter in order to ease the understanding
of what can transit through this flow.

Task: #1860054
PR: #25622
2018-07-11 12:25:33 +02:00
XavierDo 62591c58f8 [FIX] mail: add ability to mark failure notification as read
The mark as read button was not working for mail failure. More than that,
we wanted a functionnality to be able to massively mark mail failure as canceled,
especially to be able to clean databases from failure after migration.

Task: #1860054
PR: #25622
2018-07-11 12:25:33 +02:00
Olivier Dony cab349e7e4 [FIX] mail: access related fields for resend as normal user 2018-06-23 03:12:05 +02:00
Olivier Dony c77d3e5531 [FIX] mail: line endings: DOS->UNIX 2018-06-23 03:12:04 +02:00
XavierDo 133eeb1bbf [ADD] mail, mass_mailing: allow a user to resend a mail with failures
When a mail is in failure state, a red envelope appears next to the message
in a thread but it was difficult to send the mail again.
This tasks will allow users to send mail again easily, or mark notification
as cancelled if the user want to ignore this failure.
A notification will appear in sender systray while mail are in failure.

Task: #46158
PR: #24628
2018-06-07 11:46:28 +02:00