Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] mail: lock mail.mail record before sending email #583

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

fernandahf
Copy link

Description of the issue/feature this PR addresses:

In this line:

https://github.com/odoo/odoo/blob/c58a34294112b9d156fd563c207aaaacb1a90eb5/addons/mail/models/mail_mail.py#L730

The changes applied in mail.mail sending the email are applied, if there is another process at the same time updating the same record, that is going to raise a concurrence error. The problem with this is the email went out already, but in Odoo, it keeps as outgoing, causing multiple emails to go out for the same record.

This commit adds a flush_recordset before sending the email, if there is another process trying to update the same record, it will be blocked and it must wait until the sending email process finishes.
The mail record will be updated as sent.

Video how it is reproduced in a clean installation (no custom changes)

Video

Current behavior before PR:

If there is a concurrence error in this:

https://github.com/odoo/odoo/blob/c58a34294112b9d156fd563c207aaaacb1a90eb5/addons/mail/models/mail_mail.py#L730

the email goes out but it's not saved as sent in Odoo.

Desired behavior after PR is merged:

If there is a concurrence error in this line:

https://github.com/odoo/odoo/blob/c58a34294112b9d156fd563c207aaaacb1a90eb5/addons/mail/models/mail_mail.py#L730

the email goes out and it's saved as sent in Odoo because it's locked by the flush.

PATCH USE

In this line:

https://github.com/odoo/odoo/blob/c58a34294112b9d156fd563c207aaaacb1a90eb5/addons/mail/models/mail_mail.py#L730

The changes applied in mail.mail sending the email
are applied, if there is another process at the same
time updating the same record, that is going
to raise a concurrence error. The problem with this
is the email went out already, but in Odoo, it keeps
as `outgoing`, causing multiple emails went out
for same record in Odoo.

This commit adds a `flush_recordset` before to
send the email, if there is another process trying
to update the same record, it will be blocked and
it must wait to sending email process finishes.
The mail record will be updated as `sent`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant