diff options
| author | Thibault Delavallée <tde@odoo.com> | 2018-03-28 14:08:36 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-03-28 16:56:16 +0200 |
| commit | a2511f3a5aeb0ea33c52f96d785f2d8f4da847dc (patch) | |
| tree | 07818e98e48df61a3c13966b3c01ca675c4fb333 /addons/mail/models/mail_thread.py | |
| parent | 1e4ee402a359c0b061439d95b27acc0d446db204 (diff) | |
[IMP] mail: use xmlid_to_res_id instead of ref to find subtype in various post methods
As explained in previous commit we can use xmlid_to_res_id instead of ref()
which leads to some query gain. We gain 1 query on most post due notably to
notify and logging is still improved. This leads to a gain of about 4K queries
on community runbot.
Diffstat (limited to 'addons/mail/models/mail_thread.py')
| -rw-r--r-- | addons/mail/models/mail_thread.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index d41689fdf04..1b52ec94e5d 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -461,7 +461,7 @@ class MailThread(models.AbstractModel): """ self.ensure_one() # get the subtype of the comment Message - subtype_comment = self.env.ref('mail.mt_comment') + subtype_comment = self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment') # get the ids of the comment and not-comment of the thread # TDE check: sudo on mail.message, to be sure all messages are moved ? @@ -1986,7 +1986,7 @@ class MailThread(models.AbstractModel): 'message_type': 'notification', 'partner_ids': partner_ids, 'model': False, - 'subtype_id': self.env['ir.model.data'].sudo().xmlid_to_res_id('mail.mt_note'), + 'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'), 'record_name': False, 'reply_to': self.env['mail.thread'].sudo()._notify_get_reply_to([0])[0], 'message_id': tools.generate_tracking_message_id('message-notify'), @@ -2020,7 +2020,7 @@ class MailThread(models.AbstractModel): 'message_type': message_type, 'model': kwargs.get('model', self._name), 'res_id': self.ids[0] if self.ids else False, - 'subtype_id': self.env.ref('mail.mt_note').id, + 'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'), 'record_name': False, 'reply_to': self.env['mail.thread'].sudo()._notify_get_reply_to([0])[0], 'message_id': tools.generate_tracking_message_id('message-notify'), |
