From 356a42166082f9448b7e82393caeb00839be8c8f Mon Sep 17 00:00:00 2001 From: XavierDo Date: Thu, 11 Oct 2018 12:32:51 +0000 Subject: [PATCH] [FIX] mail: avoid sending mail when creating record from data Before this fix the creation of task assigned to admin was leading to the creation of mails. This is a generic fix to avoid to notifiy a user when he is add as a follower when creating data from odoo data files. closes odoo/odoo#27682 --- addons/mail/models/mail_thread.py | 2 ++ addons/test_mail/tests/test_performance.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index f6e31c9f32c..5083773bbea 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2339,6 +2339,8 @@ class MailThread(models.AbstractModel): """ if not self or self.env.context.get('mail_auto_subscribe_no_notify'): return + if not self.env.registry.ready: # Don't send notification during install + return view = self.env['ir.ui.view'].browse(self.env['ir.model.data'].xmlid_to_res_id(template)) diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index eebabca82b4..ef99b2cb3b3 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -361,6 +361,7 @@ class TestHeavyMailPerformance(TransactionCase): self.env.ref('mail.mt_comment').id, self.env.ref('test_mail.st_mail_test_child_full').id] ) + self.patch(self.env.registry, 'ready', True) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') @users('__system__', 'emp') @@ -595,7 +596,7 @@ class TestHeavyMailPerformance(TransactionCase): def test_complex_tracking_template(self): """ Write performance test involving assignation, tracking with template """ customer_id = self.customer.id - + self.assertTrue(self.env.registry.ready, "We need to simulate that registery is ready") rec = self.env['mail.test.full'].create({ 'name': 'Test', 'umbrella_id': self.umbrella.id,