diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index e171c9cc14c..50f636c3c5b 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -134,7 +134,10 @@ class mail_group(osv.Model): params = { 'search_view_id': search_ref and search_ref[1] or False, 'domain': [('model', '=', 'mail.group'), ('res_id', '=', mail_group_id)], - 'context': {'default_model': 'mail.group', 'default_res_id': mail_group_id, 'search_default_message_unread': True}, + 'context': {'default_model': 'mail.group', + 'default_res_id': mail_group_id, + 'search_default_message_unread': True, + 'mail_read_keep_unread':True}, 'res_model': 'mail.message', 'thread_level': 1, 'header_description': vals.get('description'), diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index d545f3782b4..831e1e4b162 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -501,6 +501,11 @@ class mail_message(osv.Model): if ids is None: ids = self.search(cr, uid, domain, context=context, limit=limit) + # if requested: mark messages as read + if context and context.has_key('mail_read_set_read'): + notif_ids = notif_obj.search(cr, uid, [('message_id', '=', msg.id)], context=context) + notif_obj.write(cr, uid, notif_ids, {'read': True}, context=context) + # fetch parent if threaded, sort messages for message in self.browse(cr, uid, ids, context=context): message_id = message.id diff --git a/addons/mail/tests/test_message_read.py b/addons/mail/tests/test_message_read.py index ebb39c92a02..46dd29a5431 100644 --- a/addons/mail/tests/test_message_read.py +++ b/addons/mail/tests/test_message_read.py @@ -80,6 +80,14 @@ class test_mail_access_rights(TestMailBase): elif msg.get('type') == 'expandable': new_msg_exp = msg + # #check notification For message readable or unread. + # notif_msg1_ids1 = self.mail_notification.search(cr, uid, [('partner_id', '=', user_bert.partner_id.id),('message_id', '=', message1.id)], context=context) + # notif_data1 = self.mail_notification.read(cr, uid, notif_msg1_ids1, ['read'])[0]['read'] + # # Test: Message1 are marked as read. + # self.assertTrue(notif_data1, 'Message1 are set as read for the user Bert that read it') + # #Pass key in context for unread message.. + # context.update({'default_model': 'mail.group', 'default_res_id': [self.group_pigs_id], 'mail_keep_unread': True}) + # Do: fetch new messages in first thread, domain from expandable self.assertIsNotNone(new_msg_exp, 'message_read on last Pigs message should have returned a new messages expandable') domain = new_msg_exp.get('domain', [])