[FIX] mail: set message_main_attachment_id to copy=False

Create a record.
Add an attachment set as message_main_attachment_id (e.g. through log note).
Duplicate that record.
The new record has the message_main_attachment_id of the old record,
while it has no attachments.

Since attachments security is linked to the record id, we shall not copy them.

opw 1950403

closes odoo/odoo#31846

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
This commit is contained in:
Nans Lefebvre
2019-03-14 09:40:11 +00:00
parent ac4ef455c4
commit c68a97a255
+1 -1
View File
@@ -110,7 +110,7 @@ class MailThread(models.AbstractModel):
'Number of error', compute='_compute_message_has_error',
help="Number of messages with delivery error")
message_attachment_count = fields.Integer('Attachment Count', compute='_compute_message_attachment_count')
message_main_attachment_id = fields.Many2one(string="Main Attachment", comodel_name='ir.attachment', index=True)
message_main_attachment_id = fields.Many2one(string="Main Attachment", comodel_name='ir.attachment', index=True, copy=False)
@api.one
@api.depends('message_follower_ids')