[IMP] portal: simplify the portal access wizard and generalize it to several partners
bzr revid: rco@openerp.com-20120918080306-gebronsl568xpan1
This commit is contained in:
@@ -75,7 +75,6 @@ class wizard(osv.osv_memory):
|
||||
_description = 'Portal Access Management'
|
||||
|
||||
_columns = {
|
||||
'partner_id': fields.many2one('res.partner', required=True, string="Partner"),
|
||||
'portal_id': fields.many2one('res.groups', domain=[('is_portal', '=', True)], required=True,
|
||||
string='Portal', help="The portal that users can be added in or removed from."),
|
||||
'user_ids': fields.one2many('portal.wizard.user', 'wizard_id', string='Users'),
|
||||
@@ -83,23 +82,18 @@ class wizard(osv.osv_memory):
|
||||
help="This text is included in the welcome email sent to the users."),
|
||||
}
|
||||
|
||||
def _default_partner(self, cr, uid, context):
|
||||
return context and context.get('active_id') or False
|
||||
|
||||
def _default_portal(self, cr, uid, context):
|
||||
portal_ids = self.pool.get('res.groups').search(cr, uid, [('is_portal', '=', True)])
|
||||
return portal_ids and portal_ids[0] or False
|
||||
|
||||
_defaults = {
|
||||
'partner_id': _default_partner,
|
||||
'portal_id': _default_portal,
|
||||
}
|
||||
|
||||
def onchange_portal_id(self, cr, uid, ids, partner_id, portal_id, context=None):
|
||||
assert partner_id
|
||||
def onchange_portal_id(self, cr, uid, ids, portal_id, context=None):
|
||||
# for each partner, determine corresponding portal.wizard.user records
|
||||
res_partner = self.pool.get('res.partner')
|
||||
partner_ids = [partner_id]
|
||||
partner_ids = context and context.get('active_ids') or []
|
||||
user_changes = []
|
||||
for partner in res_partner.browse(cr, SUPERUSER_ID, partner_ids, context):
|
||||
for contact in (partner.child_ids or [partner]):
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Portal Access Management" version="7.0">
|
||||
<group>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="portal_id" widget="selection" on_change="onchange_portal_id(partner_id, portal_id)"/>
|
||||
<field name="portal_id" widget="selection" on_change="onchange_portal_id(portal_id, context)"/>
|
||||
</group>
|
||||
<label string="Fill in check boxes below to determine which contacts should belong to the portal."/>
|
||||
<field name="user_ids"/>
|
||||
|
||||
Reference in New Issue
Block a user