diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py index b327bd33d98..ed2ff74fc5d 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_mail_features.py @@ -524,7 +524,7 @@ class test_mail(TestMailBase): # 1. mass_mail on pigs and bird compose_id = mail_compose.create(cr, uid, - {'subject': _subject, 'body': '${object.description}'}, + {'subject': _subject, 'body': '${object.description}', 'partner_ids': [(4, p_c_id), (4, p_d_id)]}, {'default_composition_mode': 'mass_mail', 'default_model': 'mail.group', 'default_res_id': False, 'active_ids': [self.group_pigs_id, group_bird_id]}) compose = mail_compose.browse(cr, uid, compose_id) @@ -540,11 +540,19 @@ class test_mail(TestMailBase): test_msg_ids = self.mail_message.search(cr, uid, [], limit=2) self.assertIn(message1.id, test_msg_ids, 'Pigs did not receive its mass mailing message') self.assertIn(message2.id, test_msg_ids, 'Bird did not receive its mass mailing message') - # Test: mail.message: subject, body - self.assertEqual(message1.subject, _subject, 'mail.message subject incorrect') - self.assertEqual(message1.body, '
%s
' % group_pigs.description, 'mail.message body incorrect') - self.assertEqual(message2.subject, _subject, 'mail.message subject incorrect') - self.assertEqual(message2.body, '%s
' % group_bird.description, 'mail.message body incorrect') + # Test: mail.message: subject, body, subtype, notified partners (nobody + specific recipients) + self.assertEqual(message1.subject, _subject, + 'message_post: mail.message in mass mail subject incorrect') + self.assertEqual(message1.body, '%s
' % group_pigs.description, + 'message_post: mail.message in mass mail body incorrect') + self.assertEqual(set([p.id for p in message1.notified_partner_ids]), set([p_c_id, p_d_id]), + 'message_post: mail.message in mass mail incorrect notified partners') + self.assertEqual(message2.subject, _subject, + 'message_post: mail.message in mass mail subject incorrect') + self.assertEqual(message2.body, '%s
' % group_bird.description, + 'message_post: mail.message in mass mail body incorrect') + self.assertEqual(set([p.id for p in message2.notified_partner_ids]), set([p_c_id, p_d_id]), + 'message_post: mail.message in mass mail incorrect notified partners') def test_30_needaction(self): """ Tests for mail.message needaction. """ diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 5776a8e46c5..0591d7fd932 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -218,9 +218,12 @@ class mail_compose_message(osv.TransientModel): post_values.update(email_dict) # post the message subtype = 'mail.mt_comment' - if is_log: + if is_log or mass_mail_mode: subtype = False - active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **post_values) + msg_id = active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **post_values) + # mass_mailing: notify specific partners, because subtype was False, and no-one was notified + if mass_mail_mode and post_values['partner_ids']: + self.pool.get('mail.notification')._notify(cr, uid, msg_id, post_values['partner_ids'], context=context) return {'type': 'ir.actions.act_window_close'}