Skip to content
Snippets Groups Projects
Commit c112361b authored by Renaud Thiry's avatar Renaud Thiry Committed by Thibault Delavallée
Browse files

[FIX] mail, web_editor: dialog file update event


HOW TO REPRODUCE

Go on a record (e.g. a lead), open the full composer and use the "File / Image"
button from the editor to insert an image. After sending the attachment is
displayed in chatter. However after a few days it disappears, being garbage
collected.

ISSUE

When adding an image inside a mail composer via the /image command or 'image'
button of the editor, the related attachment was never processed. This makes
sense as we do not want to attach it to the resulting message(s). However as
the attachment res_id and res_model were never updated from the compositor in
which they originated, they would become dangling attachments and be garbage
collected the next day (or the in the next pass of the GC) by
'_gc_lost_attachments'.

The attachment keeps 'mail.compose.message' as res_model and 0 as res_id.
It is therefore considered as a lost attachment and removed by the garbage
collect of attachments. As image are inlined in the content (using a link
towards /web/image) they are not part of 'attachment_ids' given to the
'message_post' method and therefore not linked to the document by
'_message_post_process_attachments' whose job is to correctly set the
model and res_id of attachments linked to the composer.

An event was not called on uploading files in a media dialog. This means the
parent of html field didn't know of the new attachments which resulted in
attachments being linked to no record at all and not being garbage collected
later. This fix makes that call.

The attachments newly uploaded in media dialog are uneditable to prevent users
from unlinking attachments that are still used in the body of the composer
(causing the same issue).

Task-2860761

closes odoo/odoo#95537

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent b16f850d
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment