[imp] create contact for portal
bzr revid: ara@tinyerp.com-20120607064833-5gv36exs0l9bmmhc
This commit is contained in:
parent
a93cdd0dc1
commit
680cc5a05f
|
@ -132,6 +132,24 @@ class wizard(osv.osv_memory):
|
|||
user_obj = self.pool.get('res.users')
|
||||
context.update({'portal_id':portal_id})
|
||||
user_list = self._default_user_ids(cr, uid, context=context)
|
||||
|
||||
contact_user = [u['user_email'] for u in user_list]
|
||||
|
||||
#add active portal user to portal wizard
|
||||
portal_users = self.pool.get('res.portal').browse(cr,uid,portal_id).group_id.users
|
||||
active_user =[]
|
||||
for u in portal_users:
|
||||
if u.partner_id.id == context['active_id'] and u.user_email not in contact_user:
|
||||
active_user.append({
|
||||
'name': u.name,
|
||||
'user_email': u.user_email,
|
||||
'lang': u.context_lang or 'en_US',
|
||||
'partner_id': u.partner_id.id or False,
|
||||
'has_portal_user':True,
|
||||
})
|
||||
if active_user:
|
||||
user_list.extend(active_user)
|
||||
|
||||
return {'value': {'user_ids': user_list}}
|
||||
|
||||
def action_create(self, cr, uid, ids, context=None):
|
||||
|
@ -151,13 +169,16 @@ class wizard(osv.osv_memory):
|
|||
portal_obj = self.pool.get('res.portal')
|
||||
for wiz in self.browse(cr, uid, ids, context):
|
||||
# determine existing users
|
||||
|
||||
portal_user=[user.id for user in wiz.portal_id.group_id.users]
|
||||
add_users=[]
|
||||
for u in wiz.user_ids:
|
||||
login_cond = [('login', 'in', [u.user_email])]
|
||||
existing_uids = user_obj.search(cr, ROOT_UID, login_cond)
|
||||
existing_users = user_obj.browse(cr, ROOT_UID, existing_uids)
|
||||
existing_logins = [user.login for user in existing_users]
|
||||
new_users_data = []
|
||||
if existing_uids:
|
||||
add_users.append(existing_uids[0])
|
||||
|
||||
if u.user_email not in existing_logins:
|
||||
new_users_data.append({
|
||||
|
@ -172,13 +193,11 @@ class wizard(osv.osv_memory):
|
|||
} )
|
||||
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)])
|
||||
user_obj.unlink(cr,uid,portal_uids)
|
||||
# send email to all users (translated in their language)
|
||||
|
||||
if add_users not in portal_user:
|
||||
portal_obj.write(cr, ROOT_UID, [wiz.portal_id.id],
|
||||
{'users': [(6, 0, add_users)]}, context0)
|
||||
|
||||
data = {
|
||||
'company': user.company_id.name,
|
||||
'message': wiz.message or "",
|
||||
|
|
Loading…
Reference in New Issue