Nimesh Contractor(Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp-read_unread-nco
into lp:~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp.
Requested reviews:
Atul Patel(OpenERP) (atp-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp-read_unread-nco/+merge/125417
Hello sir,
I have set the context for read unread.
Thanks,
NCO.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail_message_read_unread-atp-read_unread-nco/+merge/125417
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-20 06:00:28 +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_group_view.xml'
--- mail/mail_group_view.xml 2012-09-05 16:31:35 +0000
+++ mail/mail_group_view.xml 2012-09-20 06:00:28 +0000
@@ -6,6 +6,7 @@
<field name="name">Discussion Group</field>
<field name="tag">mail.wall</field>
<field name="res_model">mail.message</field>
+ <field name="context">{'mail_keep_unread': True}</field>
</record>
<!-- Group Kanban View !-->
=== modified file 'mail/mail_message.py'
--- mail/mail_message.py 2012-09-18 15:05:44 +0000
+++ mail/mail_message.py 2012-09-20 06:00:28 +0000
@@ -245,6 +245,7 @@
"""
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)
@@ -252,6 +253,9 @@
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-20 06:00:28 +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-20 06:00:28 +0000
@@ -677,3 +677,30 @@
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)
+
+ # 0 - Admin
+ p_a_id = user_admin.partner_id.id
+ # 1 - Bert Tartopoils, with email, should receive emails for comments and emails
+ p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'})
+ # 2 - Carine Poilvache, with email, should never receive emails
+ p_c_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c', 'notification_email_send': 'email'})
+ # 3 - Dédé Grosbedon, without email, to test email verification; should receive emails for every message
+ p_d_id = self.res_partner.create(cr, uid, {'name': 'Dédé Grosbedon', 'notification_email_send': 'all'})
+
+ # Subscribe #1, #2
+ group_pigs.message_subscribe([p_b_id, p_c_id])
+
+ msg1 = group_pigs.message_post(body='My Body', subject='1')
+ context = {'default_model': 'mail.group', 'default_res_id': [self.group_pigs_id]}
+ self.mail_message.message_read(cr, uid, ids=False, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)], thread_level=2, limit=10,context=context)
+ if not context.has_key('mail_keep_unread'):
+ notif_ids = self.mail_notification.search(cr, uid, [('partner_id', '=', user_admin.partner_id.id),('message_id', '=', msg1)], context=context)
+ na_count = len(notif_ids)
+ self.assertTrue(len(notif_ids), 'unread notifications')
+ self.mail_notification.write(cr, uid, notif_ids, {'read': True}, context=context)
_______________________________________________
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