[FIX] mail: avoid re-reading a value given to create
After a message is created with a given `author_id`, reuse `author_id` instead of `message.author_id.id`.
This commit is contained in:
@@ -1900,8 +1900,8 @@ class MailThread(models.AbstractModel):
|
||||
if not subtype_rec.internal:
|
||||
# done with SUPERUSER_ID, because on some models users can post only with read access, not necessarily write access
|
||||
self.sudo().write({'message_last_post': fields.Datetime.now()})
|
||||
if new_message.author_id and model and self.ids and message_type != 'notification' and not self._context.get('mail_create_nosubscribe'):
|
||||
self.message_subscribe([new_message.author_id.id], force=False)
|
||||
if author_id and model and self.ids and message_type != 'notification' and not self._context.get('mail_create_nosubscribe'):
|
||||
self.message_subscribe([author_id], force=False)
|
||||
|
||||
self._message_post_after_hook(new_message)
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class TestPerformance(TransactionCase):
|
||||
|
||||
records.write({'value': self.int(20)})
|
||||
|
||||
@queryCount(admin=20, demo=33)
|
||||
@queryCount(admin=19, demo=29)
|
||||
def test_write_mail_with_tracking(self):
|
||||
""" Write records inheriting from 'mail.thread' (with field tracking). """
|
||||
record = self.env['test_performance.mail'].search([], limit=1)
|
||||
@@ -180,7 +180,7 @@ class TestPerformance(TransactionCase):
|
||||
model = self.env['test_performance.mail']
|
||||
model.with_context(tracking_disable=True).create({'name': self.str('X')})
|
||||
|
||||
@queryCount(admin=40, demo=58)
|
||||
@queryCount(admin=39, demo=55)
|
||||
def test_create_mail_with_tracking(self):
|
||||
""" Create records inheriting from 'mail.thread' (with field tracking). """
|
||||
model = self.env['test_performance.mail']
|
||||
|
||||
Reference in New Issue
Block a user