[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
This commit is contained in:
Toufik Ben Jaa
2018-11-02 11:49:43 +00:00
parent 1d0e49bcff
commit 079a3b602b
+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')
message_main_attachment_id = fields.Many2one(string="Main Attachment", comodel_name='ir.attachment', index=True)
@api.one
@api.depends('message_follower_ids')