From c4e6874e234e0db39f69ffab94927d1d1b9d69e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 20 Apr 2012 14:09:48 +0200 Subject: [PATCH] [IMP] mail.thread: added the hiding method. However, this won t work with automatic subscriptions. Will need to be managed. Updating mail.js to be able to hide subtypes. bzr revid: tde@openerp.com-20120420120948-er9xsc575fjf04mc --- addons/mail/mail_thread.py | 16 ++++++++++++++++ addons/mail/static/src/js/mail.js | 10 +++++----- addons/mail/static/src/xml/mail.xml | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 393ec38f2cc..2d09e440af1 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -783,6 +783,22 @@ class mail_thread(osv.osv): subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) return True + def message_subscription_hide(self, cr, uid, ids, subtype=None, context=None): + """Hide notifications, allowing to tune the messages displayed on + the Wall. + :param subtype: a mail.message subtype. If None, it is means the + user wants to hide all notifications coming from + the document. + """ + subscription_obj = self.pool.get('mail.subscription') + subscription_hide_obj = self.pool.get('mail.subscription.hide') + # find the related subscriptions + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', '=', uid)], context=context) + # hide it + for subscription_id in subscription_ids: + subscription_hide_obj.create(cr, uid, {'subscription_id': subscription_id, 'subtype': subtype}, context=context) + return True + #------------------------------------------------------ # Notification API #------------------------------------------------------ diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 160a1dc33fd..835b1bcb828 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -190,12 +190,12 @@ openerp.mail = function(session) { }); // event: click on 'hide this type' in wheel_menu this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_hide_type', 'click', function (event) { - console.log('hiding type'); + //console.log('hiding type'); if (! confirm(_t("Do you really want to hide this thread ?"))) { return false; } - var msg_id = event.srcElement.dataset.id; - if (! msg_id) return false; - console.log(msg_id); - //var call_defer = self.ds.call('message_remove_pushed_notifications', [[self.params.res_id], [parseInt(msg_id)], true]); + var subtype = event.srcElement.dataset.subtype; + if (! subtype) return false; + //console.log(subtype); + var call_defer = self.ds.call('message_subscription_hide', [[self.params.res_id], subtype]); $(event.srcElement).parents('li.oe_mail_thread_msg').eq(0).hide(); if (self.params.thread_level > 0) { $(event.srcElement).parents('ul.oe_mail_thread').eq(0).hide(); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index de21d510202..76d60341254 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -60,8 +60,8 @@
menu