diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index 6e3baad57a8..7da72f95fac 100644 --- a/addons/mail/__init__.py +++ b/addons/mail/__init__.py @@ -30,6 +30,7 @@ import res_partner import report import wizard import res_config +import mail_group_menu # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/data/mail_demo.xml b/addons/mail/data/mail_demo.xml index 8be63f22804..e3d7c2ab1e1 100644 --- a/addons/mail/data/mail_demo.xml +++ b/addons/mail/data/mail_demo.xml @@ -2,49 +2,22 @@ - - A cool attachment - PT1Tb21lIGNvb2wgYXR0YWNobWVudD09ClByYWVzZW50IHZlbCBtYXNzYSBzZWQgbWFzc2EgY29uc2VxdWF0IGVnZXN0YXMgaW4gdHJpc3RpcXVlIG9yY2ku - a_cool_attachment - - Mail group - mail.group - - binary - - - - Another clean attachment - PT1Tb21lIGNsZWFuIGF0dGFjaG1lbnQ9PQpOdWxsYSB0dXJwaXMgbGVvLCByaG9uY3VzIHV0IGVnZXN0YXMgc2l0IGFtZXQsIGNvbnNlY3RldHVyIHZpdGFlIHVybmEu - a_clean_attachment - - Mail group - mail.group - - binary - - Internal company announce mail.group - + html - sit amet, consectetur adipiscing elit. Pellentesque et quam sapien, in sagittis tellus. -Praesent vel massa sed massa consequat egestas in tristique orci. Praesent iaculis libero et neque vehicula iaculis. Vivamus placerat tincidunt orci ac ornare. Proin ut dolor fringilla velit ultricies consequat. Maecenas sit amet ipsum non leo interdum imperdiet. Donec sapien mi, varius a consequat id, consectetur sit amet nulla. - -Fusce tempus elit volutpat mi auctor adipiscing. Nam congue luctus suscipit. Duis vestibulum dapibus enim vitae dignissim. Sed tellus libero, venenatis ut mollis ut, luctus quis dui. Sed rhoncus pulvinar orci in consectetur. - -Nulla turpis leo, rhoncus ut egestas sit amet, consectetur vitae urna. Mauris in dolor in sapien tempus vehicula.]]> + comment - mail.group - + html - tremendous blogpost ! (first comment)]]> + comment @@ -52,29 +25,17 @@ Nulla turpis leo, rhoncus ut egestas sit amet, consectetur vitae urna. Mauris in mail.group - + html - + comment - - Author's full biography - PT1BYm91dCB0aGUgYXV0aG9yPT0KSW50ZWdlciBzb2RhbGVzIGRvbG9yIGV1IGVsaXQgZnJpbmdpbGxhIGJsYW5kaXQu - blogpost_author_biography - - Mail group - mail.group - - binary - - mail.group - + html comment - diff --git a/addons/mail/data/mail_group_data.xml b/addons/mail/data/mail_group_data.xml index 09a6ca29a2d..443b43b62d6 100644 --- a/addons/mail/data/mail_group_data.xml +++ b/addons/mail/data/mail_group_data.xml @@ -2,16 +2,14 @@ - - All Company - All company users can come here and discuss. - Sales + Discussion about best sales practices and deals. All Employees + Discussion about best sales practices and deals. diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 82dcb4bc50b..d9519caf6d3 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -40,7 +40,7 @@ class mail_group(osv.Model): _description = 'Discussion group' _name = 'mail.group' _inherit = ['mail.thread'] - _inherits = {'mail.alias': 'alias_id'} + _inherits = {'mail.alias': 'alias_id', 'ir.ui.menu': 'menu_id'} def _get_image(self, cr, uid, ids, name, args, context=None): result = dict.fromkeys(ids, False) @@ -64,15 +64,18 @@ class mail_group(osv.Model): return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64')) _columns = { - 'name': fields.char('Name', size=64, required=True), + #'name': fields.char('Group Name', size=64, required=True), 'description': fields.text('Description'), + 'menu_id': fields.many2one('ir.ui.menu', string='Related Menu', required=True, ondelete="cascade"), 'responsible_id': fields.many2one('res.users', string='Responsible', ondelete='set null', required=True, select=1, help="Responsible of the group that has all rights on the record."), - 'public': fields.boolean('Visible by non members', help='This group is visible by non members. \ + 'public': fields.selection([('public','Public'),('private','Private'),('groups','Selected Group Only')], 'Privacy', required=True, + help='This group is visible by non members. \ Invisible groups can add members through the invite button.'), + 'group_public_id': fields.many2one('res.groups', string='Authorized Group'), 'group_ids': fields.many2many('res.groups', rel='mail_group_res_group_rel', - id1='mail_group_id', id2='groups_id', string='Linked groups', + id1='mail_group_id', id2='groups_id', string='Auto Subscription', help="Members of those groups will automatically added as followers. "\ "Note that they will be able to manage their subscription manually "\ "if necessary."), @@ -98,15 +101,25 @@ class mail_group(osv.Model): "Use this field anywhere a small image is required."), 'last_month_msg_nbr': fields.function(_get_last_month_msg_nbr, type='integer', string='Messages count for last month'), - 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True, + 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", help="The email address associated with this group. New emails received will automatically " "create new topics."), } + def _get_default_employee_group(self, cr, uid, context=None): + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user') + return ref and ref[1] or False + + def _get_menu_parent(self, cr, uid, context=None): + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'mail_group_root') + return ref and ref[1] or False + _defaults = { - 'public': True, + 'public': 'groups', + 'group_public_id': _get_default_employee_group, 'responsible_id': (lambda s, cr, uid, ctx: uid), 'image': _get_default_image, + 'parent_id': _get_menu_parent, } def _subscribe_user_with_group_m2m_command(self, cr, uid, ids, group_ids_command, context=None): @@ -129,9 +142,25 @@ class mail_group(osv.Model): {'alias_name': "group_"+name}, model_name=self._name, context=context) vals['alias_id'] = alias_id + mail_group_id = super(mail_group, self).create(cr, uid, vals, context) + + # Create client action for this group and link the menu to it + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'action_mail_group_feeds') + if ref: + search_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'view_message_search_wall') + params = { + 'search_view_id': search_ref and search_ref[1] or False, + 'domain': [('model','=','mail.group'),('res_id','=',mail_group_id)], + 'res_model': 'mail.group', + 'res_id': mail_group_id, + 'thread_level': 2 + } + cobj = self.pool.get('ir.actions.client') + newref = cobj.copy(cr, uid, ref[1], default={'params': str(params), 'name': vals['name']}, context=context) + self.write(cr, uid, [mail_group_id], {'action': 'ir.actions.client,'+str(newref), 'mail_group_id': mail_group_id}, context=context) + alias_pool.write(cr, uid, [vals['alias_id']], {"alias_force_thread_id": mail_group_id}, context) - if vals.get('group_ids'): self._subscribe_user_with_group_m2m_command(cr, uid, [mail_group_id], vals.get('group_ids'), context=context) diff --git a/addons/mail/mail_group_menu.py b/addons/mail/mail_group_menu.py new file mode 100644 index 00000000000..38756f69928 --- /dev/null +++ b/addons/mail/mail_group_menu.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-today OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see +# +############################################################################## + +from osv import osv +from osv import fields +from tools.translate import _ + +class ir_ui_menu(osv.osv): + _inherit = 'ir.ui.menu' + _columns = { + 'mail_group_id': fields.many2one('mail.group', 'Mail Group') + } + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): + ids = super(ir_ui_menu, self).search(cr, uid, args, offset=0, limit=None, order=order, context=context, count=False) + + subs = self.pool.get('mail.subscription') + for menu in self.browse(cr, uid, ids, context=context): + if menu.mail_group_id: + sub_ids = subs.search(cr, uid, [ + ('user_id','=',uid),('res_model','=','mail.group'), + ('res_id','=',menu.mail_group_id.id) + ], context=context) + if not sub_ids: + ids.remove(menu.id) + return ids + diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 4f25ba300be..cbbe999f7d5 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -1,6 +1,11 @@ + + Discussion Group + mail.wall + + @@ -55,31 +60,25 @@
- - - + +
+
+
+

+ +
+
+ + + + + - -
-
-
-

-
- -
-
- - - - - - - - - + +
@@ -101,7 +100,7 @@ - + @@ -131,6 +130,7 @@ - + + diff --git a/addons/mail/security/mail_security.xml b/addons/mail/security/mail_security.xml index 34fcbac3088..e73279b1ad7 100644 --- a/addons/mail/security/mail_security.xml +++ b/addons/mail/security/mail_security.xml @@ -1,6 +1,6 @@ - + @@ -20,23 +20,8 @@ Mail.group: access only public and joined groups - ['|', ('public', '=', True), ('member_ids', 'in', user.id)] - - - - - Mail.group: delete my groups only - - [('responsible_id', '=', user.id)] - - - - - - Mail.group: all groups - - [(1,'=',1)] - + + ['|', '|', ('public', '=', 'public'), ('member_ids', 'in', [user.id]), '&', ('public','=','groups'), ('group_public_id','in', [x.id for x in user.groups_id])] diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index faf5ada2491..500d0b9c138 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -907,8 +907,11 @@ openerp.mail = function(session) { this.params.limit = params.limit || 25; this.params.domain = params.domain || []; this.params.context = params.context || {}; + this.params.res_model = params.res_model || false; + this.params.res_id = params.res_id || false; this.params.search_view_id = params.search_view_id || false; this.params.thread_level = params.thread_level || 1; + this.params.title = params.title || false; this.comments_structure = {'root_ids': [], 'new_root_ids': [], 'msgs': {}, 'tree_struct': {}, 'model_to_root_ids': {}}; this.display_show_more = true; this.thread_list = []; @@ -953,9 +956,10 @@ openerp.mail = function(session) { if (this.compose_message_widget) { this.compose_message_widget.destroy(); } + debugger; this.compose_message_widget = new mail.ComposeMessage(this, { - 'extended_mode': false, 'uid': this.session.uid, 'res_model': 'res.users', - 'res_id': this.session.uid, 'mode': mode || 'comment', 'msg_id': msg_id }); + 'extended_mode': false, 'uid': this.session.uid, 'res_model': this.params.res_model, + 'res_id': this.params.res_id, 'mode': mode || 'comment', 'msg_id': msg_id }); var composition_node = this.$element.find('div.oe_mail_wall_action'); composition_node.empty(); var compose_done = this.compose_message_widget.appendTo(composition_node); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 3fedbbab60b..7f49b7f3943 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -16,7 +16,10 @@

- All Feeds + + News Feeds + +