[IMP] create user when user not in current userlist
bzr revid: ara@tinyerp.com-20120606053215-4dnotn7dq5o6119g
This commit is contained in:
parent
1e49be80c9
commit
a93cdd0dc1
|
@ -158,21 +158,22 @@ class wizard(osv.osv_memory):
|
|||
existing_users = user_obj.browse(cr, ROOT_UID, existing_uids)
|
||||
existing_logins = [user.login for user in existing_users]
|
||||
new_users_data = []
|
||||
if u.has_portal_user:
|
||||
if u.user_email not in existing_logins:
|
||||
new_users_data.append({
|
||||
'name': u.name,
|
||||
'login': u.user_email,
|
||||
'password': random_password(),
|
||||
'user_email': u.user_email,
|
||||
'context_lang': u.lang,
|
||||
'share': True,
|
||||
'action_id': wiz.portal_id.home_action_id and wiz.portal_id.home_action_id.id or False,
|
||||
'partner_id': u.partner_id and u.partner_id.id,
|
||||
} )
|
||||
portal_obj.write(cr, ROOT_UID, [wiz.portal_id.id],
|
||||
{'users': [(0, 0, data) for data in new_users_data]}, context0)
|
||||
else:
|
||||
|
||||
if u.user_email not in existing_logins:
|
||||
new_users_data.append({
|
||||
'name': u.name,
|
||||
'login': u.user_email,
|
||||
'password': random_password(),
|
||||
'user_email': u.user_email,
|
||||
'context_lang': u.lang,
|
||||
'share': True,
|
||||
'action_id': wiz.portal_id.home_action_id and wiz.portal_id.home_action_id.id or False,
|
||||
'partner_id': u.partner_id and u.partner_id.id,
|
||||
} )
|
||||
portal_obj.write(cr, ROOT_UID, [wiz.portal_id.id],
|
||||
{'users': [(0, 0, data) for data in new_users_data]}, context0)
|
||||
|
||||
if not u.has_portal_user:
|
||||
new_users_data = []
|
||||
if u.user_email in existing_logins:
|
||||
portal_uids = user_obj.search(cr, ROOT_UID, [('login','=',u.user_email),('partner_id', '=', u.partner_id.id)])
|
||||
|
@ -243,6 +244,10 @@ class wizard_user(osv.osv_memory):
|
|||
(_check_email, 'Invalid email address', ['email']),
|
||||
]
|
||||
|
||||
_defaults = {
|
||||
'lang': lambda self,cr,uid,c: self.browse(cr, uid, uid, c).partner_id.lang or 'en_US',
|
||||
}
|
||||
|
||||
wizard_user()
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<data>
|
||||
<!-- wizard action on res.partner -->
|
||||
<act_window id="partner_wizard_action"
|
||||
name="Portal Access Management Wizard"
|
||||
name="Portal Access Management"
|
||||
src_model="res.partner"
|
||||
res_model="res.portal.wizard"
|
||||
view_type="form" view_mode="form"
|
||||
|
@ -12,12 +12,12 @@
|
|||
|
||||
<!-- wizard view -->
|
||||
<record id="wizard_view" model="ir.ui.view">
|
||||
<field name="name">Portal Access Management Wizard</field>
|
||||
<field name="name">Portal Access Management</field>
|
||||
<field name="model">res.portal.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add Portal Access">
|
||||
<field name="portal_id" widget="selection" on_change="onchange_portal_id(portal_id,context)"/>
|
||||
<field name="portal_id" on_change="onchange_portal_id(portal_id,context)"/>
|
||||
<newline/>
|
||||
<notebook colspan="4">
|
||||
<page string="Users">
|
||||
|
|
Loading…
Reference in New Issue