From 665c1035fc3b8f1ee3da6b382b5f37d255df6ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Wed, 11 Sep 2019 15:07:43 +0000 Subject: [PATCH] [IMP] mail: call _add_default_followers only once in create There was no reason to call the method many times in the loop as its result does not depend on `vals_list`. PR: #36654 Part of task-2070602 --- addons/mail/models/mail_thread.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index e0bc166a1a9..6344fb74fba 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -260,9 +260,10 @@ class MailThread(models.AbstractModel): # subscribe uid unless asked not to if not self._context.get('mail_create_nosubscribe'): + default_followers = self.env['mail.followers']._add_default_followers(self._name, [], self.env.user.partner_id.ids, customer_ids=[])[0][0] for values in vals_list: message_follower_ids = values.get('message_follower_ids') or [] - message_follower_ids += [(0, 0, fol_vals) for fol_vals in self.env['mail.followers']._add_default_followers(self._name, [], self.env.user.partner_id.ids, customer_ids=[])[0][0]] + message_follower_ids += [(0, 0, fol_vals) for fol_vals in default_followers] values['message_follower_ids'] = message_follower_ids threads = super(MailThread, self).create(vals_list)