[IMP]: ADD Host choice and rename module to Import_sugarcrm

bzr revid: atp@tinyerp.com-20110318090234-0r4ci3o5a3eqjmm0
This commit is contained in:
Atul Patel (OpenERP) 2011-03-18 14:32:34 +05:30
parent e6fdd5d460
commit e2183df759
13 changed files with 15 additions and 11 deletions

View File

@ -23,7 +23,7 @@
'name': 'Import SugarCRM Data into OpenERP Module.',
'version': '1.0',
'category': 'Generic Modules',
'description': """This Module Import SugarCRM "Leads", "Opportunity", "Accounts" and "contacts" Data into OpenERP Module.""",
'description': """This Module Import SugarCRM "Leads", "Opportunities", and "Users" Data into OpenERP Module.""",
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': ['crm'],

View File

@ -52,7 +52,7 @@ def import_users(sugar_obj, cr, uid, context=None):
'.id' : '.id',
}
user_obj = sugar_obj.pool.get('res.users')
PortType,sessionid = sugar.login(context.get('username',''), context.get('password',''))
PortType,sessionid = sugar.login(context.get('username',''), context.get('password',''), context.get('url',''))
sugar_data = sugar.search(PortType,sessionid, 'Users')
for val in sugar_data:
user_ids = user_obj.search(cr, uid, [('login', '=', val.get('user_name'))])
@ -130,7 +130,7 @@ def import_leads(sugar_obj, cr, uid, context=None):
}
lead_obj = sugar_obj.pool.get('crm.lead')
PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''))
PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
sugar_data = sugar.search(PortType, sessionid, 'Leads')
for val in sugar_data:
val['type'] = 'lead'
@ -152,7 +152,7 @@ def import_opportunities(sugar_obj, cr, uid, context=None):
'type' : 'type',
}
lead_obj = sugar_obj.pool.get('crm.lead')
PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''))
PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
sugar_data = sugar.search(PortType, sessionid, 'Opportunities')
for val in sugar_data:
val['type'] = 'opportunity'

View File

@ -9,7 +9,7 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Sugarcrm">
<group colspan="4" >
<group colspan="4" width="400" col="3">
<separator string="Select SugarCRM Module Name" colspan="4"/>
<field name="lead" />
<field name="opportunity" />

View File

@ -29,10 +29,10 @@ import sys;
class LoginError(Exception): pass
def login(username, password):
def login(username, password, url):
loc = sugarsoapLocator()
portType = loc.getsugarsoapPortType()
portType = loc.getsugarsoapPortType(url)
request = loginRequest()
uauth = ns0.user_auth_Def(request)
request._user_auth = uauth

View File

@ -20,7 +20,7 @@
##############################################################################
from osv import fields, osv
from tools.translate import _
from sugarcrm_syncro import sugar
from import_sugarcrm import sugar
class sugarcrm_login(osv.osv):
"""SugarCRM Login"""
@ -30,23 +30,25 @@ class sugarcrm_login(osv.osv):
_columns = {
'username': fields.char('User Name', size=64, required=True),
'password': fields.char('Password', size=24,required=True),
'url' : fields.char('SugarCRM Path', size=264, required=True, help="Path for SugarCRM connection should be 'http://localhost/sugarcrm/soap.php' Format."),
}
_defaults = {
'username' : 'admin',
'password' : 'admin',
'url': "http://localhost/sugarcrm/soap.php"
}
def open_import(self, cr, uid, ids, context=None):
for current in self.browse(cr, uid, ids, context):
PortType,sessionid = sugar.login(current.username, current.password)
PortType,sessionid = sugar.login(current.username, current.password, current.url)
if sessionid == '-1':
raise osv.except_osv(_('Error !'), _('Authentication error !\nBad Username or Password !'))
obj_model = self.pool.get('ir.model.data')
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','import.sugarcrm.form')])
resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])
context.update({'rec_id': ids, 'username': current.username, 'password': current.password})
context.update({'rec_id': ids, 'username': current.username, 'password': current.password, 'url': current.url})
return {
'view_type': 'form',
'view_mode': 'form',

View File

@ -9,7 +9,9 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Sugarcrm Login">
<group colspan="4" >
<group colspan="4" width="500" >
<separator string="Please Enter Path to Connect with SugarCRM" colspan="4"/>
<field name="url" colspan="4" widget="url"/>
<separator string="Please enter your user name and password." colspan="4"/>
<field name="username"/>
<newline/>