diff options
| author | Martin Trigaux <mat@openerp.com> | 2013-04-03 17:10:56 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@openerp.com> | 2013-04-03 17:10:56 +0200 |
| commit | 46110fbf2995f3a8104f3f08007db4cf43000a85 (patch) | |
| tree | 7ef224499a8f332014eb4a40b3bc1ca5adc6a2d4 /addons/mail | |
| parent | 788501fd7804a45319d7776a381d2e6f42215df7 (diff) | |
[ADD] option to globally stop showing group suggestions
bzr revid: mat@openerp.com-20130403151056-4vjno2k9n77drm6y
Diffstat (limited to 'addons/mail')
| -rw-r--r-- | addons/mail/mail_group.py | 9 | ||||
| -rw-r--r-- | addons/mail/res_users.py | 12 | ||||
| -rw-r--r-- | addons/mail/static/src/css/mail.css | 10 | ||||
| -rw-r--r-- | addons/mail/static/src/js/suggestions.js | 8 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/suggestions.xml | 9 |
5 files changed, 40 insertions, 8 deletions
diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 24aed942b1b..14fd0a20880 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -200,3 +200,12 @@ class mail_group(osv.Model): """ Wrapper because message_unsubscribe_users take a user_ids=None that receive the context without the wrapper. """ 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""" + user = self.pool.get('res.users').browse(cr, uid, uid, context) + if not user.display_groups_suggestions: + return [] + else: + return super(mail_group, self).get_suggested_thread(cr, uid, removed_suggested_threads, context) diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index f7c91939b98..4fe7e34aec7 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -28,6 +28,7 @@ class res_users(osv.Model): - add a preference about sending emails about notifications - make a new user follow itself - add a welcome message + - add suggestion preference """ _name = 'res.users' _inherit = ['res.users'] @@ -37,10 +38,12 @@ 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"), } _defaults = { 'alias_domain': False, # always hide alias during creation + 'display_groups_suggestions': True, } def __init__(self, pool, cr): @@ -51,10 +54,10 @@ class res_users(osv.Model): init_res = super(res_users, self).__init__(pool, cr) # duplicate list to avoid modifying the original reference self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS) - self.SELF_WRITEABLE_FIELDS.append('notification_email_send') + self.SELF_WRITEABLE_FIELDS.extend(['notification_email_send', 'display_groups_suggestions']) # duplicate list to avoid modifying the original reference self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS) - self.SELF_READABLE_FIELDS.extend(['notification_email_send', 'alias_domain', 'alias_name']) + self.SELF_READABLE_FIELDS.extend(['notification_email_send', 'alias_domain', 'alias_name', 'display_groups_suggestions']) return init_res def _auto_init(self, cr, context=None): @@ -156,6 +159,11 @@ 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): + """Update display_groups_suggestions value to False""" + if context is None: context = {} + self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context) + class res_users_mail_group(osv.Model): """ Update of res.users class diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index d22b58bde74..9076ae0387e 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -683,7 +683,7 @@ width: 300px; } -.openerp .oe_mail_wall_aside > div { +.openerp .oe_mail_wall_aside .oe_sidebar_suggestion { background-color: #EDEDF6; border-radius: 2px; padding: 10px; @@ -710,16 +710,18 @@ .openerp .oe_mail_wall_aside .oe_suggestion_action { margin-top: 10px; } -.openerp .oe_mail_wall_aside .oe_remove_suggested_item { +.openerp .oe_mail_wall_aside .oe_remove_suggested_item, +.openerp .oe_mail_wall_aside .oe_remove_suggestion { visibility:hidden; width:3%; float:right; margin-right:20px; } -.openerp .oe_mail_wall_aside .oe_suggested_item:hover .oe_remove_suggested_item > span { +.openerp .oe_mail_wall_aside .oe_suggested_item:hover .oe_remove_suggested_item > span, +.openerp .oe_mail_wall_aside .oe_suggestion_display:hover .oe_remove_suggestion > span { visibility: visible; } -.openerp .oe_mail_wall_aside .oe_item { +.openerp .oe_mail_wall_aside .oe_item,.oe_suggestion_display { width: 90%; } .openerp .oe_mail_wall_aside .oe_item .oe_item_name { diff --git a/addons/mail/static/src/js/suggestions.js b/addons/mail/static/src/js/suggestions.js index 137607a7643..ad0867f4930 100644 --- a/addons/mail/static/src/js/suggestions.js +++ b/addons/mail/static/src/js/suggestions.js @@ -16,6 +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_suggested_group': "remove_suggested_group", 'click .oe_join_group': "join_group", 'click .oe_open_group': "open_group" @@ -25,6 +26,7 @@ openerp.mail.suggestions = function(session, mail) { this._super(parent, action); this.deferred = $.Deferred(); this.mail_group = new session.web.DataSetSearch(this, 'mail.group'); + this.res_users = new session.web.DataSetSearch(this, 'res.users'); this.suggestions = []; }, start: function() { @@ -70,6 +72,12 @@ openerp.mail.suggestions = function(session, mail) { var self = this; removed_suggested_group.push($(event.currentTarget).attr('id')); self.get_suggested_group(); + }, + remove_employee_suggestions: function(event) { + var self = this; + return this.res_users.call('stop_showing_group_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 949e421143c..1ebd2f6276c 100644 --- a/addons/mail/static/src/xml/suggestions.xml +++ b/addons/mail/static/src/xml/suggestions.xml @@ -6,8 +6,13 @@ </t> <!-- Suggested groups --> - <div t-name="mail.suggestions.groups" class="oe_sidebar_group"> - <p class="oe_suggestion_display">Suggested Groups</p> + <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"> + <span class="oe_kanban_action oe_kanban_action_a">X</span> + </a> + </p> <div class="oe_suggest_groups"> <t t-foreach="widget.suggestions" t-as="result"> <div class="oe_suggested_item"> |
