Antony Lesuisse (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp/+merge/125849
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp/+merge/125849
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp.
=== modified file 'mail/mail_group.py'
--- mail/mail_group.py 2012-09-14 04:27:25 +0000
+++ mail/mail_group.py 2012-09-22 12:57:25 +0000
@@ -125,7 +125,7 @@
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},
+ 'context': {'default_model': 'mail.group', 'default_res_id': mail_group_id, 'mail_keep_unread':True},
'res_model': 'mail.message',
'thread_level': 1,
}
=== modified file 'mail/mail_message.py'
--- mail/mail_message.py 2012-09-18 15:05:44 +0000
+++ mail/mail_message.py 2012-09-22 12:57:25 +0000
@@ -245,13 +245,16 @@
"""
limit = limit or self._message_read_limit
context = context or {}
+ notif_obj = self.pool.get("mail.notification")
if not ids:
ids = self.search(cr, uid, domain, context=context, limit=limit)
messages = self.browse(cr, uid, ids, context=context)
-
result = []
tree = {} # key: ID, value: record
for msg in messages:
+ if not context.has_key('mail_keep_unread'):
+ notif_ids = notif_obj.search(cr, uid, [('message_id', '=', msg.id)], context=context)
+ notif_obj.write(cr, uid, notif_ids, {'read': True}, context=context)
if len(result) < (limit - 1):
record = self._message_dict_get(cr, uid, msg, context=context)
if thread_level and msg.parent_id:
=== modified file 'mail/mail_message_view.xml'
--- mail/mail_message_view.xml 2012-09-07 06:36:57 +0000
+++ mail/mail_message_view.xml 2012-09-22 12:57:25 +0000
@@ -91,14 +91,14 @@
<field name="name">News Feed</field>
<field name="tag">mail.wall</field>
<field name="params" eval=""{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid])],
- 'context': {'default_model': 'res.users', 'default_res_id': uid} }""/>
+ 'context': {'default_model': 'res.users', 'default_res_id': uid, 'mail_keep_unread': True} }""/>
</record>
<record id="action_mail_my_feeds" model="ir.actions.client">
<field name="name">My Feeds</field>
<field name="tag">mail.wall</field>
<field name="params" eval=""{'domain': [('author_id.user_ids', 'in', [uid])],
- 'context': {'default_model': 'res.users', 'default_res_id': uid} }""/>
+ 'context': {'default_model': 'res.users', 'default_res_id': uid, 'mail_keep_unread': True} }""/>
</record>
</data>
</openerp>
=== modified file 'mail/tests/test_mail.py'
--- mail/tests/test_mail.py 2012-09-18 15:05:17 +0000
+++ mail/tests/test_mail.py 2012-09-22 12:57:25 +0000
@@ -677,3 +677,41 @@
msg1.refresh()
# Test: msg1 has Bert as voter
self.assertEqual(set(msg1.vote_user_ids), set([user_bert]), 'after unvoting for Admin, Bert is not the voter')
+
+ def test_70_read_unread(self):
+ """ Test designed for the message read or unread feature. """
+ cr, uid = self.cr, self.uid
+ group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id)
+ user_admin = self.res_users.browse(cr, uid, uid)
+
+ # Create user Bert Tartopoils
+ user_bert_id = self.res_users.create(cr, uid, {'name': 'Bert', 'login': 'bert'})
+ user_bert = self.res_users.browse(cr, uid, user_bert_id)
+ #subscribe Bert Tartopoils
+ group_pigs.message_subscribe([user_bert.partner_id.id])
+ #Post two new message into pigs group
+ msg1 = group_pigs.message_post(body='My Body', subject='1')
+ msg2 = group_pigs.message_post(body='My Body', subject='2')
+ message1 = self.mail_message.browse(cr, uid, msg1)
+ message2 = self.mail_message.browse(cr, uid, msg2)
+ context= {}
+ #Test : Groups contain two messages.
+ self.assertEqual(2, len(group_pigs.message_ids), 'group should contain 2 messages')
+ #Read message without key. using bert parner
+ msg_data1 = self.mail_message.message_read(cr, user_bert.id, ids=[message1.id], domain=[], thread_level=2, limit=10,context=context)
+ #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})
+ # Test: New created Message2 are set as unread.
+ msg_data2 = self.mail_message.message_read(cr, uid, ids=[message2.id], domain=[], thread_level=2, limit=10,context=context)
+ #Check Notification For unread message..
+ notif_msg2_ids2 = self.mail_notification.search(cr, uid, [('partner_id', '=', user_admin.partner_id.id),('message_id', '=', message2.id)], context=context)
+ notif_data2 = self.mail_notification.read(cr, uid, notif_msg2_ids2, ['read'])[0]['read']
+ self.assertFalse(notif_data2, 'Newly created Message2 are set as unread')
+ # Check there are 1 needaction on mail.message with particular domain
+ na_count = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)])
+ self.assertEqual(na_count, 1, 'posted message count does not match needaction count')
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp