diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index f07af1c524f..b108f3d061e 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -1079,6 +1079,9 @@ class Message(models.Model): if pid and pid == author_id and not self.env.context.get('mail_notify_author'): # do not notify the author of its own messages continue if pid: + if active is False: + # avoid to notify inactive partner by email (odoobot) + continue pdata = {'id': pid, 'active': active, 'share': pshare, 'groups': groups} if notif == 'inbox': recipient_data['partners'].append(dict(pdata, notif=notif, type='user')) diff --git a/addons/test_mail/tests/test_discuss.py b/addons/test_mail/tests/test_discuss.py index 3f27a20f4b0..f182e7f6a55 100644 --- a/addons/test_mail/tests/test_discuss.py +++ b/addons/test_mail/tests/test_discuss.py @@ -96,6 +96,20 @@ class TestNotifications(BaseFunctionalTest, MockEmails): body='Test', message_type='comment', subtype='mail.mt_comment', partner_ids=[self.user_employee.partner_id.id]) + def test_inactive_follower(self): + # In some case odoobot is follower of a record. + # Even if it shouldn't be the case, we want to be sure that odoobot is not notified + self.test_record._message_subscribe(self.user_employee.partner_id.ids) + with self.assertNotifications(partner_employee=(1, 'inbox', 'unread')): + self.test_record.message_post( + body='Test', message_type='comment', subtype='mail.mt_comment') + self.user_employee.active = False + # at this point, partner is still active and would receive an email notification + self.user_employee.partner_id._write({'active': False}) + with self.assertNotifications(partner_employee=(0, '', '')): + self.test_record.message_post( + body='Test', message_type='comment', subtype='mail.mt_comment') + def test_set_message_done_user(self): with self.assertNotifications(partner_employee=(0, '', '')): message = self.test_record.message_post( diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py index 9a8d9e6411f..1a796b07501 100644 --- a/addons/test_mail/tests/test_mail_gateway.py +++ b/addons/test_mail/tests/test_mail_gateway.py @@ -486,14 +486,18 @@ class TestMailgateway(BaseFunctionalTest, MockEmails): @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models', 'odoo.addons.mail.models.mail_mail') def test_private_discussion(self): """ Testing private discussion between partners. """ - msg1_pids = [self.env.user.partner_id.id, self.partner_1.id] + self.partner_2 = self.env['res.partner'].with_context(BaseFunctionalTest._test_context).create({ + 'name': 'Admin', + 'email': 'admin@agrolait.com', + }) + msg1_pids = [self.partner_1.id, self.partner_2.id] # Do: Raoul writes to Bert and Administrator, with a model specific by parameter that should not be taken into account msg1 = self.env['mail.thread'].sudo(self.user_employee).message_post(partner_ids=msg1_pids, subtype='mail.mt_comment', model='mail.test') # Test: message recipients msg = self.env['mail.message'].browse(msg1.id) - self.assertEqual(msg.partner_ids, self.env.user.partner_id | self.partner_1, + self.assertEqual(msg.partner_ids, self.partner_2 | self.partner_1, 'message_post: private discussion: incorrect recipients') self.assertEqual(msg.model, False, 'message_post: private discussion: parameter model not correctly ignored when having no res_id') @@ -510,7 +514,7 @@ class TestMailgateway(BaseFunctionalTest, MockEmails): # Test: message recipients self.assertEqual(msg2.author_id, self.partner_1, 'message_post: private discussion: wrong author through mailgateway based on email') - self.assertEqual(msg2.partner_ids, self.user_employee.partner_id | self.env.user.partner_id, + self.assertEqual(msg2.partner_ids, self.user_employee.partner_id | self.partner_2, 'message_post: private discussion: incorrect recipients when replying') # Do: Bert replies through chatter (is a customer) @@ -518,9 +522,9 @@ class TestMailgateway(BaseFunctionalTest, MockEmails): # Test: message recipients msg = self.env['mail.message'].browse(msg3.id) - self.assertEqual(msg.partner_ids, self.user_employee.partner_id | self.env.user.partner_id, + self.assertEqual(msg.partner_ids, self.user_employee.partner_id | self.partner_2, 'message_post: private discussion: incorrect recipients when replying') - self.assertEqual(msg.needaction_partner_ids, self.user_employee.partner_id | self.env.user.partner_id, + self.assertEqual(msg.needaction_partner_ids, self.user_employee.partner_id | self.partner_2, 'message_post: private discussion: incorrect notified recipients when replying') @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models', 'odoo.addons.mail.models.mail_mail') diff --git a/addons/website_sale/static/src/js/website_sale_tour_shop_mail.js b/addons/website_sale/static/src/js/website_sale_tour_shop_mail.js index c8343ef33e5..601f7a2759e 100644 --- a/addons/website_sale/static/src/js/website_sale_tour_shop_mail.js +++ b/addons/website_sale/static/src/js/website_sale_tour_shop_mail.js @@ -70,9 +70,20 @@ tour.register('shop_mail', { trigger: '.btn[name="action_quotation_send"]', extra_trigger: '.o_statusbar_status .btn-primary:contains("Sales Order")', }, + { + content: "Open recipients dropdown", + trigger: '.o_field_many2one[name="partner_ids"] .ui-autocomplete-input', + run: 'click', + }, + { + content: "Select azure interior", + trigger: '.ui-menu-item a:contains(Interior24)', + in_modal: false, + }, { content: "click Send email", trigger: '.btn[name="action_send_mail"]', + extra_trigger: '.o_badge_text:contains("Azure")', }, { content: "wait mail to be sent, and go see it",