Denis Ledoux 272359b86c [FIX] mail: accurate message notifications marked as sent
When multiple emails (`mail.mail`) are linked
to the same message (`mail.message`),
all the message notifications were being marked as sent
as soon as one of the mail was sent, and not all of them.

This is indeed possible to have multiple emails linked to a single
message, for instance when there are employees and customers in
the followers of a thread, and some must therefore have
the buttons meant for the employees ("Assign me") and some not.

In other words, it was possible notifications were marked
as sent while their associated email was not sent yet.

This revision also comes as an addition to
5d6656d739

as it was possible to receive a bounce coming from
the previous mail sent which wrote on the same notifications `email_status`
than the current message being sent before we could acquire the lock on
them (see commit message of the above mentioned revision),
as it was writing the `email_status` on more notifications that it
should have, including notifications of the previous email.

e.g
- Mail 1
- Message 1
- Recipient A, B, C
- Mail 2
- Message 1
- Recipient D, E

Let's say recipient A bounces

If the email notifying the bounce arrives during the processing of the "Mail 1",
it will be blocked until we release the lock on the `mail.notification` `email_status`
we acquire thanks to having written `exception` on `email_status` before sending the email.
But, as soon as it is unblocked (after the `cr.commit()`),
it will immediately re-attempt the delivery of the bounce email,
therefore writting "bounced" in `email_status` of recipient A,
while the transaction of the second email already began.
When the second email sending will try to write the `email_status`
of recipient A as well
(as it used to write the `email_status` on all the message notifications,
not just the one related to the current email),
it raised a concurrent update.
Therefore:
1. Interrupting the loop, as psycopg2 exceptions are raised and not passed,
2. Replay the sending of the second email a second time.

opw-1984293

closes odoo/odoo#33431

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-05-16 12:57:57 +00:00
2017-06-23 16:34:23 +02:00
2019-05-07 08:03:28 +00:00
2015-09-08 15:45:09 +02:00
2016-12-19 14:19:26 +01:00
2015-09-08 17:58:38 +02:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, Purchase Management, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

If you are a developer you may type the following command at your terminal:

wget -O- https://raw.githubusercontent.com/odoo/odoo/10.0/setup/setup_dev.py | python

Then follow the developer tutorials

For Odoo employees

To add the odoo-dev remote use this command:

$ ./setup/setup_dev.py setup_git_dev

To fetch odoo merge pull requests refs use this command:

$ ./setup/setup_dev.py setup_git_review
S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%