diff --git a/addons/portal/__init__.py b/addons/portal/__init__.py index 0d6d510dbe6..5aea1cf958f 100644 --- a/addons/portal/__init__.py +++ b/addons/portal/__init__.py @@ -20,4 +20,5 @@ ############################################################################## import portal +import wizard diff --git a/addons/portal/__openerp__.py b/addons/portal/__openerp__.py index ca664c6b4d3..012403a1a52 100644 --- a/addons/portal/__openerp__.py +++ b/addons/portal/__openerp__.py @@ -38,7 +38,7 @@ module 'share'. """, 'website': 'http://www.openerp.com', 'demo_xml': [], - 'data': ['portal_view.xml'], + 'data': ['portal_view.xml', 'wizard_view.xml'], 'installable': True, 'certificate' : '', } diff --git a/addons/portal/portal_view.xml b/addons/portal/portal_view.xml index c3ed6106821..74872f61a67 100644 --- a/addons/portal/portal_view.xml +++ b/addons/portal/portal_view.xml @@ -31,8 +31,10 @@ portal's users. - + + diff --git a/addons/portal/wizard.py b/addons/portal/wizard.py new file mode 100644 index 00000000000..410aa806c67 --- /dev/null +++ b/addons/portal/wizard.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2011 Tiny SPRL (). +# +# 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, fields +from tools.translate import _ + +class groups_wizard(osv.osv_memory): + _name = 'res.portal.groups' + _description = 'Portal Groups Wizard' + _columns = { + 'portal_id': fields.many2one('res.portal', required=True, readonly=True, + string='Portal'), + 'add_group_ids': fields.many2many('res.groups', + 'portal_groups_add', 'portal_groups_id', 'group_ids', + string='Add Groups'), + 'remove_group_ids': fields.many2many('res.groups', + 'portal_groups_remove', 'portal_groups_id', 'group_ids', + string='Remove Groups'), + } + _defaults = { + 'portal_id': (lambda self,cr,uid,context: context and context.get('active_id')) + } + + def do_apply(self, cr, uid, ids, context=None, *args): + assert len(ids) == 1 + wizard = self.browse(cr, uid, ids[0], context) + + # select all portal users except admin + user_ids = [u.id for u in wizard.portal_id.user_ids if u.id != 1] + + # apply group adds and removals to portal users + add_gids = [(4, g.id) for g in wizard.add_group_ids] + rem_gids = [(3, g.id) for g in wizard.remove_group_ids] + user_values = {'groups_id': add_gids + rem_gids} + self.pool.get('res.users').write(cr, uid, user_ids, user_values, context) + + # return an empty dictionary to close the wizard window + return {} + +groups_wizard() + diff --git a/addons/portal/wizard_view.xml b/addons/portal/wizard_view.xml new file mode 100644 index 00000000000..f748292ede6 --- /dev/null +++ b/addons/portal/wizard_view.xml @@ -0,0 +1,51 @@ + + + + + + Add/Remove Groups + res.portal.groups + form + form + new + + + + + Portal Groups Wizard + res.portal.groups + form + + +
+ + + + + + + + +