From 079a3b602bf26b54d11532b29d28d41e310a8786 Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Fri, 2 Nov 2018 11:49:43 +0000 Subject: [PATCH] [FIX] mail: add index on `message_main_attachment_id` - When deleting attachments, the foreign key constraints on `message_main_attachment_id` are triggered which could take a lot of time to be computed. closes odoo/odoo#28358 --- 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 93a99011520..5082fc981a7 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') + message_main_attachment_id = fields.Many2one(string="Main Attachment", comodel_name='ir.attachment', index=True) @api.one @api.depends('message_follower_ids')