From c68a97a255b86af03625bdfc9697e7199efa35e8 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Thu, 14 Mar 2019 09:40:08 +0000 Subject: [PATCH] [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) --- addons/mail/models/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 9f76813eac2..9153628b83b 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -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')