[ADD] option to globally stop showing employeep suggestions

bzr revid: mat@openerp.com-20130403152443-3jqg0v182mcqsk0f
This commit is contained in:
Martin Trigaux 2013-04-03 17:24:43 +02:00
parent 46110fbf29
commit 52ddce88f3
7 changed files with 27 additions and 8 deletions

View File

@ -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:

View File

@ -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,

View File

@ -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();
});
}
});

View File

@ -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 []

View File

@ -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)

View File

@ -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();
});
}

View File

@ -9,7 +9,7 @@
<div t-name="mail.suggestions.groups" class="oe_sidebar_suggestion oe_sidebar_group">
<p class="oe_suggestion_display">
Suggested Groups
<a class="oe_remove_suggestion oe_remove_suggestion_employees" rol="button">
<a class="oe_remove_suggestion oe_remove_suggestion_groups" rol="button">
<span class="oe_kanban_action oe_kanban_action_a">X</span>
</a>
</p>