diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 172b91aaf0d..15b3cdee6df 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -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) diff --git a/odoo/addons/test_performance/tests/test_performance.py b/odoo/addons/test_performance/tests/test_performance.py index 72a28e29f1a..6d9e179c299 100644 --- a/odoo/addons/test_performance/tests/test_performance.py +++ b/odoo/addons/test_performance/tests/test_performance.py @@ -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']