summaryrefslogtreecommitdiff
path: root/addons/mail/wizard/mail_compose_message.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-03-28 14:15:11 +0200
committerThibault Delavallée <tde@odoo.com>2018-03-28 16:57:05 +0200
commit4451e505cd9505ddd862b4312daec26089e9c7d1 (patch)
treede95a57b75017ad9d9b2d26138a7314e2fc822d9 /addons/mail/wizard/mail_compose_message.py
parenta2511f3a5aeb0ea33c52f96d785f2d8f4da847dc (diff)
[IMP] mail: use xmlid_to_res_id instead of ref in remaining places of mail
As explained in previous commit we can use xmlid_to_res_id instead of ref() which leads to some query gain. This commit update some other less important places: when setting activities as done and in the composer. This lead to a gain in tests involving activities and composer, including tracking triggering a template. On community runbot this leads to a gain of about 1K queries.
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
-rw-r--r--addons/mail/wizard/mail_compose_message.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 573e54898b4..4cc06574ec4 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -123,7 +123,7 @@ class MailComposer(models.TransientModel):
domain="[('model', '=', model)]")
# mail_message updated fields
message_type = fields.Selection(default="comment")
- subtype_id = fields.Many2one(default=lambda self: self.sudo().env.ref('mail.mt_comment', raise_if_not_found=False).id)
+ subtype_id = fields.Many2one(default=lambda self: self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment'))
@api.multi
def check_access_rule(self, operation):
@@ -239,7 +239,7 @@ class MailComposer(models.TransientModel):
elif wizard.subtype_id:
subtype_id = wizard.subtype_id.id
else:
- subtype_id = self.sudo().env.ref('mail.mt_comment', raise_if_not_found=False).id
+ subtype_id = self.env['ir.model.data'].xmlid_to_res_id('mail.mt_comment')
for res_ids in sliced_res_ids:
batch_mails = Mail