From 52ddce88f338d8c904efe6b652f1a236da2763fc Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 3 Apr 2013 17:24:43 +0200 Subject: [PATCH] [ADD] option to globally stop showing employeep suggestions bzr revid: mat@openerp.com-20130403152443-3jqg0v182mcqsk0f --- addons/hr/__init__.py | 1 + addons/hr/hr.py | 10 ++++++++++ addons/hr/static/src/js/suggestions.js | 8 ++++++++ addons/mail/mail_group.py | 4 ++-- addons/mail/res_users.py | 4 ++-- addons/mail/static/src/js/suggestions.js | 6 +++--- addons/mail/static/src/xml/suggestions.xml | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/addons/hr/__init__.py b/addons/hr/__init__.py index 44f6ba69f41..aec7f83f0ce 100644 --- a/addons/hr/__init__.py +++ b/addons/hr/__init__.py @@ -23,6 +23,7 @@ import hr_department import hr import res_config +import res_users import mail_message # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr/hr.py b/addons/hr/hr.py index bdbeaa196ec..161de5e9b4f 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -309,6 +309,16 @@ class hr_employee(osv.osv): # if no overwrite, send message as usual return super(hr_employee, self).message_post(cr, uid, thread_id, context=context, **kwargs) + def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None): + """Show the suggestion of employees if display_employees_suggestions if the + user perference allows it. """ + user = self.pool.get('res.users').browse(cr, uid, uid, context) + if not user.display_employees_suggestions: + return [] + else: + return super(hr_employee, self).get_suggested_thread(cr, uid, removed_suggested_threads, context) + + _defaults = { 'active': 1, 'image': _get_default_image, diff --git a/addons/hr/static/src/js/suggestions.js b/addons/hr/static/src/js/suggestions.js index fe8dc83a37a..294143da733 100644 --- a/addons/hr/static/src/js/suggestions.js +++ b/addons/hr/static/src/js/suggestions.js @@ -6,6 +6,7 @@ openerp.hr = function(session) { var removed_suggested_employee = session.removed_suggested_employee = []; suggestions.Employees = session.mail.Wall.include({ events: { + 'click .oe_remove_suggestion_employees': "remove_suggestion_employees", 'click .oe_remove_suggested_employee': "remove_suggested_employee", 'click .oe_follow_employee': "follow_employee", 'click .oe_open_employee': "open_employee" @@ -15,6 +16,7 @@ openerp.hr = function(session) { this._super(parent, action); this.deferred = $.Deferred(); this.hr_employee = new session.web.DataSetSearch(this, 'hr.employee'); + this.res_users = new session.web.DataSetSearch(this, 'res.users'); this.suggestions = []; }, start: function() { @@ -77,6 +79,12 @@ openerp.hr = function(session) { var self = this; removed_suggested_employee.push($(event.currentTarget).attr('id')); self.get_suggested_employee(); + }, + remove_suggestion_employees: function(event) { + var self = this; + return this.res_users.call('stop_showing_employees_suggestions', [this.session.uid]).then(function(res) { + self.$(".oe_sidebar_employee").hide(); + }); } }); diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 14fd0a20880..635948a5fea 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -202,8 +202,8 @@ class mail_group(osv.Model): return self.message_unsubscribe_users(cr, uid, ids, context=context) def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None): - """Show the suggestion of users if display_groups_suggestions if the - user perference allows it display_groups_suggestions""" + """Show the suggestion of groups if display_groups_suggestions if the + user perference allows it.""" user = self.pool.get('res.users').browse(cr, uid, uid, context) if not user.display_groups_suggestions: return [] diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 4fe7e34aec7..8e7b4e74fbf 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -38,7 +38,7 @@ class res_users(osv.Model): 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, help="Email address internally associated with this user. Incoming "\ "emails will appear in the user's notifications."), - 'display_groups_suggestions': fields.boolean("Display Group Suggestions"), + 'display_groups_suggestions': fields.boolean("Display Groups Suggestions"), } _defaults = { @@ -159,7 +159,7 @@ class res_users(osv.Model): def message_create_partners_from_emails(self, cr, uid, emails, context=None): return self.pool.get('res.partner').message_create_partners_from_emails(cr, uid, emails, context=context) - def stop_showing_group_suggestions(self, cr, uid, user_id, context=None): + def stop_showing_groups_suggestions(self, cr, uid, user_id, context=None): """Update display_groups_suggestions value to False""" if context is None: context = {} self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context) diff --git a/addons/mail/static/src/js/suggestions.js b/addons/mail/static/src/js/suggestions.js index ad0867f4930..205f8b2f27d 100644 --- a/addons/mail/static/src/js/suggestions.js +++ b/addons/mail/static/src/js/suggestions.js @@ -16,7 +16,7 @@ openerp.mail.suggestions = function(session, mail) { var removed_suggested_group = session.removed_suggested_group = []; suggestions.Groups = session.web.Widget.extend({ events: { - 'click .oe_remove_suggestion_employees': "remove_employee_suggestions", + 'click .oe_remove_suggestion_groups': "remove_suggestion_groups", 'click .oe_remove_suggested_group': "remove_suggested_group", 'click .oe_join_group': "join_group", 'click .oe_open_group': "open_group" @@ -73,9 +73,9 @@ openerp.mail.suggestions = function(session, mail) { removed_suggested_group.push($(event.currentTarget).attr('id')); self.get_suggested_group(); }, - remove_employee_suggestions: function(event) { + remove_suggestion_groups: function(event) { var self = this; - return this.res_users.call('stop_showing_group_suggestions', [this.session.uid]).then(function(res) { + return this.res_users.call('stop_showing_groups_suggestions', [this.session.uid]).then(function(res) { self.$(".oe_sidebar_group").hide(); }); } diff --git a/addons/mail/static/src/xml/suggestions.xml b/addons/mail/static/src/xml/suggestions.xml index 1ebd2f6276c..d90e6b12b03 100644 --- a/addons/mail/static/src/xml/suggestions.xml +++ b/addons/mail/static/src/xml/suggestions.xml @@ -9,7 +9,7 @@

Suggested Groups - + X