diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index cbd477f55e6..b19aad1afe3 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 a52f9bcab6b..79416fb26a9 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -46,7 +46,7 @@ class mail_group(osv.osv): _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) @@ -89,15 +89,18 @@ class mail_group(osv.osv): 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."), @@ -131,15 +134,25 @@ class mail_group(osv.osv): string='Joined', multi='get_member_ids'), '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): @@ -162,9 +175,25 @@ class mail_group(osv.osv): {'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 5c81d426d6a..1ce6679788a 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -1,6 +1,11 @@ + + Discussion Group + mail.wall + + @@ -51,35 +56,29 @@
- - - + +
+
+
+

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

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