[ADD] option to globally stop showing employeep suggestions
bzr revid: mat@openerp.com-20130403152443-3jqg0v182mcqsk0f
This commit is contained in:
parent
46110fbf29
commit
52ddce88f3
|
@ -23,6 +23,7 @@ import hr_department
|
||||||
import hr
|
import hr
|
||||||
|
|
||||||
import res_config
|
import res_config
|
||||||
|
import res_users
|
||||||
import mail_message
|
import mail_message
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -309,6 +309,16 @@ class hr_employee(osv.osv):
|
||||||
# if no overwrite, send message as usual
|
# if no overwrite, send message as usual
|
||||||
return super(hr_employee, self).message_post(cr, uid, thread_id, context=context, **kwargs)
|
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 = {
|
_defaults = {
|
||||||
'active': 1,
|
'active': 1,
|
||||||
'image': _get_default_image,
|
'image': _get_default_image,
|
||||||
|
|
|
@ -6,6 +6,7 @@ openerp.hr = function(session) {
|
||||||
var removed_suggested_employee = session.removed_suggested_employee = [];
|
var removed_suggested_employee = session.removed_suggested_employee = [];
|
||||||
suggestions.Employees = session.mail.Wall.include({
|
suggestions.Employees = session.mail.Wall.include({
|
||||||
events: {
|
events: {
|
||||||
|
'click .oe_remove_suggestion_employees': "remove_suggestion_employees",
|
||||||
'click .oe_remove_suggested_employee': "remove_suggested_employee",
|
'click .oe_remove_suggested_employee': "remove_suggested_employee",
|
||||||
'click .oe_follow_employee': "follow_employee",
|
'click .oe_follow_employee': "follow_employee",
|
||||||
'click .oe_open_employee': "open_employee"
|
'click .oe_open_employee': "open_employee"
|
||||||
|
@ -15,6 +16,7 @@ openerp.hr = function(session) {
|
||||||
this._super(parent, action);
|
this._super(parent, action);
|
||||||
this.deferred = $.Deferred();
|
this.deferred = $.Deferred();
|
||||||
this.hr_employee = new session.web.DataSetSearch(this, 'hr.employee');
|
this.hr_employee = new session.web.DataSetSearch(this, 'hr.employee');
|
||||||
|
this.res_users = new session.web.DataSetSearch(this, 'res.users');
|
||||||
this.suggestions = [];
|
this.suggestions = [];
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
|
@ -77,6 +79,12 @@ openerp.hr = function(session) {
|
||||||
var self = this;
|
var self = this;
|
||||||
removed_suggested_employee.push($(event.currentTarget).attr('id'));
|
removed_suggested_employee.push($(event.currentTarget).attr('id'));
|
||||||
self.get_suggested_employee();
|
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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -202,8 +202,8 @@ class mail_group(osv.Model):
|
||||||
return self.message_unsubscribe_users(cr, uid, ids, context=context)
|
return self.message_unsubscribe_users(cr, uid, ids, context=context)
|
||||||
|
|
||||||
def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
|
def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
|
||||||
"""Show the suggestion of users if display_groups_suggestions if the
|
"""Show the suggestion of groups if display_groups_suggestions if the
|
||||||
user perference allows it display_groups_suggestions"""
|
user perference allows it."""
|
||||||
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||||
if not user.display_groups_suggestions:
|
if not user.display_groups_suggestions:
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -38,7 +38,7 @@ class res_users(osv.Model):
|
||||||
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
|
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
|
||||||
help="Email address internally associated with this user. Incoming "\
|
help="Email address internally associated with this user. Incoming "\
|
||||||
"emails will appear in the user's notifications."),
|
"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 = {
|
_defaults = {
|
||||||
|
@ -159,7 +159,7 @@ class res_users(osv.Model):
|
||||||
def message_create_partners_from_emails(self, cr, uid, emails, context=None):
|
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)
|
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"""
|
"""Update display_groups_suggestions value to False"""
|
||||||
if context is None: context = {}
|
if context is None: context = {}
|
||||||
self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context)
|
self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context)
|
||||||
|
|
|
@ -16,7 +16,7 @@ openerp.mail.suggestions = function(session, mail) {
|
||||||
var removed_suggested_group = session.removed_suggested_group = [];
|
var removed_suggested_group = session.removed_suggested_group = [];
|
||||||
suggestions.Groups = session.web.Widget.extend({
|
suggestions.Groups = session.web.Widget.extend({
|
||||||
events: {
|
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_remove_suggested_group': "remove_suggested_group",
|
||||||
'click .oe_join_group': "join_group",
|
'click .oe_join_group': "join_group",
|
||||||
'click .oe_open_group': "open_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'));
|
removed_suggested_group.push($(event.currentTarget).attr('id'));
|
||||||
self.get_suggested_group();
|
self.get_suggested_group();
|
||||||
},
|
},
|
||||||
remove_employee_suggestions: function(event) {
|
remove_suggestion_groups: function(event) {
|
||||||
var self = this;
|
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();
|
self.$(".oe_sidebar_group").hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div t-name="mail.suggestions.groups" class="oe_sidebar_suggestion oe_sidebar_group">
|
<div t-name="mail.suggestions.groups" class="oe_sidebar_suggestion oe_sidebar_group">
|
||||||
<p class="oe_suggestion_display">
|
<p class="oe_suggestion_display">
|
||||||
Suggested Groups
|
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>
|
<span class="oe_kanban_action oe_kanban_action_a">X</span>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue