← Back to team overview

openerp-dev-web team mailing list archive

lp:~openerp-dev/openobject-addons/trunk-import_sugarcrm-consistent_wizard-atp into lp:~openerp-dev/openobject-addons/trunk-import_sugarcrm

 

Atul Patel(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-import_sugarcrm-consistent_wizard-atp into lp:~openerp-dev/openobject-addons/trunk-import_sugarcrm.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_sugarcrm-consistent_wizard-atp/+merge/59915


Backlogs4:
-----------
1) Add Prefix name means sugarcrm instance name to xml_id 
2) Add tooltips in sugarcrm instance name field.
3) Send emails to users when import datas successfully.

Thanks

-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_sugarcrm-consistent_wizard-atp/+merge/59915
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-import_sugarcrm.
=== modified file 'import_sugarcrm/__openerp__.py'
--- import_sugarcrm/__openerp__.py	2011-04-14 10:39:21 +0000
+++ import_sugarcrm/__openerp__.py	2011-05-04 12:52:28 +0000
@@ -27,10 +27,11 @@
             "Contacts", "Employees", Meetings, Phonecalls, Emails, and Project, Project Tasks Data into OpenERP Module.""",
     'author': 'OpenERP SA',
     'website': 'http://www.openerp.com',
-    'depends': ['project_timesheet', 'project_issue'],
+    'depends': ['project_issue', 'project_timesheet'],
     'init_xml': [],
-    'update_xml': ["wizard/sugarcrm_login_view.xml",
+    'update_xml': ["wizard/import_sugarcrm_select_services_view.xml",
                    "wizard/import_message_view.xml",
+                   "wizard/sugarcrm_login_view.xml",
                    "import_sugarcrm_view.xml"],
     'demo_xml': [],
     'test': [],

=== modified file 'import_sugarcrm/import_sugarcrm.py'
--- import_sugarcrm/import_sugarcrm.py	2011-04-27 16:13:55 +0000
+++ import_sugarcrm/import_sugarcrm.py	2011-05-04 12:52:28 +0000
@@ -23,8 +23,12 @@
 import sugar
 import sugarcrm_fields_mapping
 from tools.translate import _
+import tools
 import pprint
+import time
+from datetime import datetime
 pp = pprint.PrettyPrinter(indent=4)
+DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
 
 
 def find_mapped_id(obj, cr, uid, res_model, sugar_id, context):
@@ -144,6 +148,7 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Contacts')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_contact_'+ val.get('id')
         if val.get('primary_address_country'):
             country_id = get_all_countries(sugar_obj, cr, uid, val.get('primary_address_country'), context)
             state = get_all_states(sugar_obj,cr, uid, val.get('primary_address_state'), country_id, context)
@@ -185,6 +190,7 @@
     sugar_data = sugar.search(PortType,sessionid, 'Users')
     for val in sugar_data:
         user_ids = user_obj.search(cr, uid, [('login', '=', val.get('user_name'))])
+        val['id'] =  context.get('instance_name')+ '_user_'+ val.get('id')
         if user_ids: 
             val['.id'] = str(user_ids[0])
         else:
@@ -317,7 +323,7 @@
                 'id': 'id',
                 'name': 'name',
                 'website': 'website',
-                'user_id/id': 'assigned_user_id',
+                'user_id/id': 'user_id/id',
                 'ref': 'sic_code',
                 'comment': ['__prettyprint__', 'description', 'employees', 'ownership', 'annual_revenue', 'rating', 'industry', 'ticker_symbol'],
                 'customer': 'customer',
@@ -328,6 +334,8 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Accounts')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_account_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id') 
         add_id = get_address(sugar_obj, cr, uid, val, context)
         val['customer'] = '1'
         val['supplier'] = '0'
@@ -466,9 +474,14 @@
         context = {}
     map_task = {'id' : 'id',
                 'name': 'name',
+<<<<<<< TREE
                 'date': 'date_start',
                 'date_deadline' : 'date_due',
                 'user_id/id': 'assigned_user_id',
+=======
+                'date': 'date_entered',
+                'user_id/id': 'user_id/id',
+>>>>>>> MERGE-SOURCE
                 'categ_id/.id': 'categ_id/.id',
                 'partner_id/.id': 'partner_id/.id',
                 'partner_address_id/.id': 'partner_address_id/.id',
@@ -479,7 +492,9 @@
     categ_id = get_category(sugar_obj, cr, uid, 'crm.meeting', 'Tasks')
     sugar_data = sugar.search(PortType, sessionid, 'Tasks')
     for val in sugar_data:
-        partner_xml_id = find_mapped_id(sugar_obj, cr, uid, 'res.partner.address', val.get('contact_id'), context)
+        val['id'] =  context.get('instance_name')+ '_task_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
+        partner_xml_id = find_mapped_id(sugar_obj, cr, uid, 'res.partner.address', context.get('instance_name')+ '_contact_'+val.get('contact_id'), context)
         if not partner_xml_id:
             raise osv.except_osv(_('Warning !'), _('Reference Contact %s cannot be created, due to Lower Record Limit in SugarCRM Configuration.') % val.get('contact_name'))
         partner_id, partner_address_id = get_account(sugar_obj, cr, uid, val, context)
@@ -499,7 +514,7 @@
     meeting_obj = sugar_obj.pool.get('crm.meeting')
     user_dict = sugar.user_get_attendee_list(PortType, sessionid, module_name, module_id)
     for user in user_dict: 
-        user_model_ids = find_mapped_id(sugar_obj, cr, uid, 'res.users', user.get('id'), context)
+        user_model_ids = find_mapped_id(sugar_obj, cr, uid, 'res.users', context.get('instance_name')+'_user_'+user.get('id'), context)
         user_resource_id = model_obj.browse(cr, uid, user_model_ids)        
         if user_resource_id:
             user_id = user_resource_id[0].res_id 
@@ -523,7 +538,7 @@
                     'duration': ['duration_hours', 'duration_minutes'],
                     'location': 'location',
                     'alarm_id/.id': 'alarm_id/.id',
-                    'user_id/id': 'assigned_user_id',
+                    'user_id/id': 'user_id/id',
                     'partner_id/.id':'partner_id/.id',
                     'partner_address_id/.id':'partner_address_id/.id',
                     'state': 'state'
@@ -532,6 +547,8 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Meetings')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_meeting_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
         partner_id, partner_address_id = get_account(sugar_obj, cr, uid, val, context)
         val['partner_id/.id'] = partner_id
         val['partner_address_id/.id'] = partner_address_id
@@ -562,7 +579,7 @@
                     'name': 'name',
                     'date': 'date_start',
                     'duration': ['duration_hours', 'duration_minutes'],
-                    'user_id/id': 'assigned_user_id',
+                    'user_id/id': 'user_id/id',
                     'partner_id/.id': 'partner_id/.id',
                     'partner_address_id/.id': 'partner_address_id/.id',
                     'categ_id/.id': 'categ_id/.id',
@@ -572,6 +589,8 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Calls')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_call_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
         categ_id = get_category(sugar_obj, cr, uid, 'crm.phonecall', val.get('direction'))         
         val['categ_id/.id'] = categ_id
         partner_id, partner_address_id = get_account(sugar_obj, cr, uid, val, context)
@@ -592,6 +611,7 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Employees')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_resource_'+ val.get('user_hash')
         fields, datas = sugarcrm_fields_mapping.sugarcrm_fields_mapp(val, map_resource)
         resource_obj.import_data(cr, uid, fields, [datas], mode='update', current_module='sugarcrm_import', noupdate=True, context=context)
     return True    
@@ -633,7 +653,7 @@
     project_obj = sugar_obj.pool.get('project.project')
     sugar_bug_project = sugar.relation_search(PortType, sessionid, 'Bugs', module_id=val.get('id'), related_module='Project', query=None, deleted=None)
     for project_id in sugar_bug_project:
-        model_ids = find_mapped_id(sugar_obj, cr, uid, 'project.project', project_id, context)
+        model_ids = find_mapped_id(sugar_obj, cr, uid, 'project.project', context.get('instance_name')+ '_project_'+project_id, context)
         if model_ids:
             model_id = model_obj.browse(cr, uid, model_ids)[0].res_id
             project_id = project_obj.browse(cr, uid, model_id).id
@@ -654,6 +674,7 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Bugs')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_bug_'+ val.get('id')
         val['project_id/.id'] = get_issue_related_project(sugar_obj,cr,uid, PortType, sessionid, val, context)
         val['categ_id.id'] = get_category(sugar_obj, cr, uid, 'project.issue', val.get('type'))
         val['priority'] = get_bug_priority(sugar_obj, cr, uid, val.get('priority'),context)
@@ -681,7 +702,7 @@
     model_obj = sugar_obj.pool.get('ir.model.data')
     mailgate_obj = sugar_obj.pool.get('mailgate.message')
     new_attachment_id = attachment_obj.create(cr, uid, {'name': val.get('name'), 'datas': File, 'res_id': val['res_id'],'res_model': val['model']})
-    message_model_ids = find_mapped_id(sugar_obj, cr, uid, model, val.get('id'), context)
+    message_model_ids = find_mapped_id(sugar_obj, cr, uid, model, context.get('instance_name')+'_note_'+val.get('id'), context)
     message_xml_id = model_obj.browse(cr, uid, message_model_ids)
     if message_xml_id:
         mailgate_obj.write(cr, uid, [message_xml_id[0].res_id], {'attachment_ids': [(4, new_attachment_id)]})             
@@ -693,8 +714,13 @@
     map_attachment = {'id' : 'id',
                       'name':'name',
                       'date':'date_entered',
+<<<<<<< TREE
                       'user_id/id': 'assigned_user_id',
                       'description': ['description', 'description_html'],
+=======
+                      'user_id/id': 'user_id/id',
+                      'description': 'description_html',
+>>>>>>> MERGE-SOURCE
                       'res_id': 'res_id',
                       'model': 'model',
                       'partner_id.id' : 'partner_id.id',
@@ -704,9 +730,17 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Notes')
     for val in sugar_data:
+<<<<<<< TREE
         File = sugar.attachment_search(PortType, sessionid, 'Notes', val.get('id'))
         model_ids = model_obj.search(cr, uid, [('name', 'like', val.get('parent_id'))])
         for model in model_obj.browse(cr, uid, model_ids):
+=======
+         val['id'] =  context.get('instance_name')+ '_note_'+ val.get('id')
+         val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
+         File = sugar.attachment_search(PortType, sessionid, 'Notes', val.get('id'))
+         model_ids = model_obj.search(cr, uid, [('name', 'like', val.get('parent_id'))])
+         for model in model_obj.browse(cr, uid, model_ids):
+>>>>>>> MERGE-SOURCE
             val['res_id'] = model.res_id
             val['model'] = model.model
         fields, datas = sugarcrm_fields_mapping.sugarcrm_fields_mapp(val, map_attachment)   
@@ -733,9 +767,10 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Employees')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_employee_'+ val.get('id')
         address_id = get_user_address(sugar_obj, cr, uid, val, context)
         val['address_home_id/.id'] = address_id
-        model_ids = find_mapped_id(sugar_obj, cr, uid, 'resource.resource', val.get('user_hash')+ '_resource_resource', context)
+        model_ids = find_mapped_id(sugar_obj, cr, uid, 'resource.resource', context.get('instance_name')+ '_resource_'+val.get('user_hash'), context)
         resource_id = sugar_obj.pool.get('ir.model.data').browse(cr, uid, model_ids)
         if resource_id:
             val['resource_id/.id'] = resource_id[0].res_id
@@ -765,8 +800,13 @@
     'email_cc': 'cc_addrs_names',
     'email_bcc': 'bcc_addrs_names',
     'message_id': 'message_id',
+<<<<<<< TREE
     'user_id/id': 'assigned_user_id',
     'description': ['description', 'description_html'],
+=======
+    'user_id/id': 'user_id/id',
+    'description': 'description_html',
+>>>>>>> MERGE-SOURCE
     'res_id': 'res_id',
     'model': 'model',
     }
@@ -775,6 +815,8 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Emails')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_email_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
         model_ids = model_obj.search(cr, uid, [('name', 'like', val.get('parent_id'))])
         for model in model_obj.browse(cr, uid, model_ids):
             val['res_id'] = model.res_id
@@ -793,7 +835,7 @@
     partner_address_obj = sugar_obj.pool.get('res.partner.address')
     sugar_project_account = sugar.relation_search(PortType, sessionid, 'Project', module_id=val.get('id'), related_module='Accounts', query=None, deleted=None)
     for account_id in sugar_project_account:
-        model_ids = find_mapped_id(sugar_obj, cr, uid, 'res.partner', account_id, context)
+        model_ids = find_mapped_id(sugar_obj, cr, uid, 'res.partner', context.get('instance_name')+'_account_'+account_id, context)
         if model_ids:
             model_id = model_obj.browse(cr, uid, model_ids)[0].res_id
             partner_id = partner_obj.browse(cr, uid, model_id).id
@@ -808,7 +850,7 @@
         'name': 'name',
         'date_start': 'estimated_start_date',
         'date': 'estimated_end_date',
-        'user_id/id': 'assigned_user_id',
+        'user_id/id': 'user_id/id',
         'partner_id/.id': 'partner_id/.id',
         'contact_id/.id': 'contact_id/.id', 
          'state': 'state'   
@@ -817,6 +859,8 @@
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'Project')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_project_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
         partner_id, partner_invoice_id = get_project_account(sugar_obj,cr,uid, PortType, sessionid, val, context) 
         val['partner_id/.id'] = partner_id
         val['contact_id/.id'] = partner_invoice_id 
@@ -839,13 +883,15 @@
         'total_hours': 'total_hours',        
         'priority': 'priority',
         'description': 'description',
-        'user_id/id': 'assigned_user_id',
+        'user_id/id': 'user_id/id',
          'state': 'state'   
     }
     task_obj = sugar_obj.pool.get('project.task')
     PortType, sessionid = sugar.login(context.get('username', ''), context.get('password', ''), context.get('url',''))
     sugar_data = sugar.search(PortType, sessionid, 'ProjectTask')
     for val in sugar_data:
+        val['id'] =  context.get('instance_name')+ '_project_task_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
         val['state'] = get_project_task_state(sugar_obj, cr, uid, val.get('status'),context)
         val['priority'] = get_project_task_priority(sugar_obj, cr, uid, val.get('priority'),context)
         fields, datas = sugarcrm_fields_mapping.sugarcrm_fields_mapp(val, map_project_task)
@@ -870,7 +916,7 @@
             'street2': 'alt_address_street',
             'zip': 'primary_address_postalcode',
             'city':'primary_address_city',
-            'user_id/id' : 'assigned_user_id',
+            'user_id/id' : 'user_id/id',
             'stage_id.id' : 'stage_id.id',
             'type' : 'type',
             'state': 'state',
@@ -882,8 +928,15 @@
     for val in sugar_data:
         if val.get('opportunity_id'):
             continue
+<<<<<<< TREE
         title_id = get_contact_title(sugar_obj, cr, uid, val.get('salutation'), 'Contact', context)
         val['title/id'] = title_id
+=======
+        val['id'] =  context.get('instance_name')+ '_lead_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
+        title_id = get_contact_title(sugar_obj, cr, uid, val.get('salutation'), 'contact', context)
+        val['title.id'] = title_id
+>>>>>>> MERGE-SOURCE
         val['type'] = 'lead'
         stage_id = get_lead_status(sugar_obj, cr, uid, val, context)
         val['stage_id.id'] = stage_id
@@ -905,7 +958,7 @@
     sugar_contact = list(sugar_account_contact.intersection(sugar_opportunities_contact))
     if sugar_contact: 
         for contact in sugar_contact:
-            model_ids = find_mapped_id(sugar_obj, cr, uid, 'res.partner.address', contact, context)
+            model_ids = find_mapped_id(sugar_obj, cr, uid, 'res.partner.address', context.get('instance_name')+'_contact_'+contact, context)
             if model_ids:
                 model_id = model_obj.browse(cr, uid, model_ids)[0].res_id
                 address_id = partner_address_obj.browse(cr, uid, model_id)
@@ -926,8 +979,13 @@
         'partner_address_id/name': 'partner_address_id/name',
         'planned_revenue': 'amount',
         'date_deadline':'date_closed',
+<<<<<<< TREE
         'user_id/id' : 'assigned_user_id',
         'stage_id/id' : 'stage_id/id',
+=======
+        'user_id/id' : 'user_id/id',
+        'stage_id.id' : 'stage_id.id',
+>>>>>>> MERGE-SOURCE
         'type' : 'type',
         'categ_id.id': 'categ_id.id'
     }
@@ -936,6 +994,8 @@
     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['id'] =  context.get('instance_name')+ '_opportunities_'+ val.get('id')
+        val['user_id/id'] = val.get('assigned_user_id') and context.get('instance_name')+ '_user_'+ val.get('assigned_user_id')
         partner_xml_id = partner_obj.search(cr, uid, [('name', 'like', val.get('account_name'))])
         if not partner_xml_id:
             raise osv.except_osv(_('Warning !'), _('Reference Partner %s cannot be created, due to Lower Record Limit in SugarCRM Configuration.') % val.get('account_name'))
@@ -1026,21 +1086,42 @@
     _name = "import.sugarcrm"
     _description = __doc__
     _columns = {
-        'opportunity': fields.boolean('Leads and Opportunities', help="If Opportunities are checked, SugarCRM opportunities data imported in OpenERP crm-Opportunity form"),
-        'user': fields.boolean('Users', help="If Users  are checked, SugarCRM Users data imported in OpenERP Users form"),
+<<<<<<< TREE
+        'opportunity': fields.boolean('Leads and Opportunities', help="If Opportunities are checked, SugarCRM opportunities data imported in OpenERP crm-Opportunity form"),
+        'user': fields.boolean('Users', help="If Users  are checked, SugarCRM Users data imported in OpenERP Users form"),
+=======
+        'username': fields.char('User Name', size=64, required=True),
+        'password': fields.char('Password', size=24,required=True),
+        'url' : fields.char('Service', size=264, required=True, help="Connection with Sugarcrm Using Soap Protocol Services and For that Path should be 'http://localhost/sugarcrm/soap.php' Format."),
+        'file': fields.binary('Select File'),
+        'email_from': fields.char('Notify End Of Import To:', size=128),
+        'opportunity': fields.boolean('Leads and Opportunities', help="If Opportunities are checked, SugarCRM opportunities data imported in OpenERP crm-Opportunity form"),
+        'user': fields.boolean('Users', help="If Users  are checked, SugarCRM Users data imported in OpenERP Users form"),
+>>>>>>> MERGE-SOURCE
         'contact': fields.boolean('Contacts', help="If Contacts are checked, SugarCRM Contacts data imported in OpenERP partner address form"),
         'account': fields.boolean('Accounts', help="If Accounts are checked, SugarCRM  Accounts data imported in OpenERP partners form"),
         'employee': fields.boolean('Employee', help="If Employees is checked, SugarCRM Employees data imported in OpenERP employees form"),
         'meeting': fields.boolean('Meetings', help="If Meetings is checked, SugarCRM Meetings data imported in OpenERP meetings form"),
         'call': fields.boolean('Calls', help="If Calls is checked, SugarCRM Calls data imported in OpenERP phonecalls form"),
+        'claim': fields.boolean('Claims', help="If Claims is checked, SugarCRM Claims data imported in OpenERP Claims form"),
         'email': fields.boolean('Emails', help="If Emails is checked, SugarCRM Emails data imported in OpenERP Emails form"),
         'project': fields.boolean('Projects', help="If Projects is checked, SugarCRM Projects data imported in OpenERP Projects form"),
         'project_task': fields.boolean('Project Tasks', help="If Project Tasks is checked, SugarCRM Project Tasks data imported in OpenERP Project Tasks form"),
+        'task': fields.boolean('Tasks', help="If Tasks is checked, SugarCRM Tasks data imported in OpenERP Meetings form"),
         'bug': fields.boolean('Bugs', help="If Bugs is checked, SugarCRM Bugs data imported in OpenERP Project Issues form"),
         'attachment': fields.boolean('Attachments', help="If Attachments is checked, SugarCRM Notes data imported in OpenERP's Related module's History with attachment"),
-        'username': fields.char('User Name', size=64),
-        'password': fields.char('Password', size=24),
+        'document': fields.boolean('Documents', help="If Documents is checked, SugarCRM Documents data imported in OpenERP Document Form"),
+        'instance_name': fields.char("Instance's Name", size=64, help="Prefix of SugarCRM id to differentiate xml_id of SugarCRM models datas come from different server."),
+        'interval_number': fields.integer('Interval Number',help="Repeat every x."),
+        'interval_type': fields.selection( [('minutes', 'Minutes'),
+            ('hours', 'Hours'), ('work_days','Work Days'), ('days', 'Days'),('weeks', 'Weeks'), ('months', 'Months')], 'Interval Unit'),
+        'numbercall': fields.integer('Number of Calls', help='Number of time the function is called,\na negative number indicates no limit'),
+        'doall' : fields.boolean('Repeat Missed', help="Enable this if you want to execute missed occurences as soon as the server restarts."),
+        'nextcall' : fields.datetime('Next Execution Date', help="Next planned execution date for this scheduler"),
+        'model': fields.char('Object', size=64, help="Name of object whose function will be called when this scheduler will run. e.g. 'res.partener'", required=True),
+        'function': fields.char('Function', size=64, help="Name of the method to be called on the object when this scheduler is executed.", required=True),
     }
+<<<<<<< TREE
     _defaults = { #to be set to true, but easier for debugging
        'opportunity': False,
        'user' : False,
@@ -1053,14 +1134,32 @@
         'project' : False,   
         'project_task': False,     
         'bug': False,
+=======
+    _defaults = {
+       'username' : 'admin',
+       'password' : 'admin',
+       'url':  "http://localhost/sugarcrm/soap.php";,
+       'instance_name': 'sugarcrm',
+       'model': 'import.sugarcrm',
+       'function': 'do_import_all',
+       'nextcall' : lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+>>>>>>> MERGE-SOURCE
     }
     
+    
     def get_key(self, cr, uid, ids, context=None):
         """Select Key as For which Module data we want import data."""
         if not context:
             context = {}
         key_list = []
         for current in self.browse(cr, uid, ids, context):
+<<<<<<< TREE
+=======
+            PortType,sessionid = sugar.login(current.username, current.password, current.url)
+            context.update({'username': current.username, 'password': current.password, 'url': current.url, 'instance_name': current.instance_name, 'email': current.email_from})
+            if sessionid == '-1':
+                raise osv.except_osv(_('Error !'), _('Authentication error !\nBad Username or Password !'))
+>>>>>>> MERGE-SOURCE
             if current.opportunity:
                 key_list.append('Opportunities')
             if current.user:
@@ -1086,11 +1185,38 @@
             if current.attachment:
                 key_list.append('Notes')                                    
         return key_list
+                 
+    def do_import_all(self, cr, uid, *args):
+        imported = set()
+        context = {}
+        login_obj = self.pool.get('sugarcrm.login')
+        if args[1]:
+            login_id = login_obj.browse(cr, uid, args[1])
+            context.update({'username': login_id.username, 'password': login_id.password, 'url': login_id.url, 'instance_name': args[3]}) 
+        for key in args[0]:
+            if not key in imported:
+                self.resolve_dependencies(cr, uid, MAP_FIELDS, MAP_FIELDS[key]['dependencies'], imported, context=context)
+                MAP_FIELDS[key]['process'](self, cr, uid, context=context)
+                imported.add(key)
+        return True 
+
+    def import_from_scheduler_all(self, cr, uid, ids, context=None):
+        keys = self.get_key(cr, uid, ids, context)
+        if not keys:
+           raise osv.except_osv(_('Warning !'), _('Select Module to Import.'))
+        cron_obj = self.pool.get('ir.cron')
+        login_obj = self.pool.get('sugarcrm.login')
+        new_login_id = login_obj.create(cr, uid, {'username': context.get('username'), 'password': context.get('password'), 'url': context.get('url')})
+        args = (keys, new_login_id, context.get('email'), context.get('instance_name'))
+        for current in self.browse(cr, uid, ids):
+             cron_obj.create(cr, uid, {'name': 'Import SugarCRM datas','interval_type': current.interval_type,'interval_number':current.interval_number,'nextcall': current.nextcall,'doall': current.doall,'numbercall': current.numbercall,'model': 'import.sugarcrm','function': current.function, 'args': args})
+        return True
 
     def import_all(self, cr, uid, ids, context=None):
         """Import all sugarcrm data into openerp module"""
         if not context:
             context = {}
+        obj_model = self.pool.get('ir.model.data')            
         keys = self.get_key(cr, uid, ids, context)
         imported = set() #to invoid importing 2 times the sames modules
         for key in keys:
@@ -1098,8 +1224,18 @@
                 self.resolve_dependencies(cr, uid, MAP_FIELDS, MAP_FIELDS[key]['dependencies'], imported, context=context)
                 MAP_FIELDS[key]['process'](self, cr, uid, context)
                 imported.add(key)
-
-        obj_model = self.pool.get('ir.model.data')
+        if keys and context.get('email'):
+            to_mail = context.get('email')
+            if to_mail:
+                from_mail = tools.config.options['email_from'] or False
+                subject = "Data Imported Successfully from SugarCRM,"
+                body = """Hello,\n\tSugarCRM "%s" Models datas has been imported Successfully on %s with login %s.\n\nThank You for using OpenERP Import SugarCRM module.\n---------\nOpenERP"""%(', '.join(keys), datetime.now().strftime(DATETIME_FORMAT), context.get('username'))
+                tools.email_send(from_mail, [to_mail], subject, body)
+            msg = """SugarCRM Models "%s" datas has been imported Successfully with  %s User and Send Emails to %s email id User.\n\nThank You for using OpenERP Import SugarCRM module."""%(', '.join(keys),context.get('username'), context.get('email'))
+            context.update({'msg': msg})
+        else:
+            msg = """SugarCRM Models "%s"  datas has been imported Successfully with %s User.\n\nThank You for using OpenERP Import SugarCRM module."""%(', '.join(keys),context.get('username'))
+            context.update({'msg':  msg})    
         model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','import.message.form')])
         resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])
         return {
@@ -1109,6 +1245,7 @@
                 'views': [(resource_id,'form')],
                 'type': 'ir.actions.act_window',
                 'target': 'new',
+                'context': context
             }
 
     def resolve_dependencies(self, cr, uid, dict, dep, imported, context=None):

=== modified file 'import_sugarcrm/import_sugarcrm_view.xml'
--- import_sugarcrm/import_sugarcrm_view.xml	2011-04-21 13:03:16 +0000
+++ import_sugarcrm/import_sugarcrm_view.xml	2011-05-04 12:52:28 +0000
@@ -3,18 +3,31 @@
     <data>
 
     <!-- Import Sugarcrm Form View -->
-        <record model="ir.ui.view" id="view_import_sugarcrm_form">
-            <field name="name">import.sugarcrm.form</field>
+        <record model="ir.ui.view" id="view_import_sugarcrm_webservices_form">
+            <field name="name">import.sugarcrm.webservice.form</field>
             <field name="model">import.sugarcrm</field>
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Import SugarCRM">
+<<<<<<< TREE
                     <group colspan="4" width="500">
                          <separator string="Select SugarCRM Module Name" colspan="4"/>
                          <group colspan="4" col="6">
+=======
+                    <group colspan="4" width="750">
+                     	<separator string="Import Your Data From:" colspan="4"/>
+						<field name="url" widget="url" colspan="4"/>
+                        <field name="username"/>
+                        <field name="password" password="True"/> 
+					<notebook colspan="4">
+						<page string="Module To Import">
+                       		<separator string="Data To Import" colspan="4"/>	
+>>>>>>> MERGE-SOURCE
                          	<field name="opportunity" />
                          	<field name= "meeting" />
+                         	<field name= "task" string="Meeting Tasks"/>
                          	<field name= "call" />
+                         	<field name= "claim" />
 	                         <field name= "account" />
 	                         <field name= "contact" />
 	                         <field name="user" />
@@ -23,34 +36,86 @@
 	                         <field name= "project" />
 	                         <field name= "project_task" />
 	                         <field name= "bug" string="Project Issue"/>
-	                         <field name= "attachment" />
-                         </group>
-                         <field name="username" invisible="1"/>
-                         <field name="password" invisible="1"/>
+	                         <field name= "document" />
+	                         <field name= "attachment" string="History and Attachment" />
+		                     <separator string="" colspan="4" />
+			                 <group colspan="4" >
+			                     <label string="" colspan="2"/>
+			                     <button  icon="gtk-cancel" special="cancel" string="_Cancel"/>
+			                     <button name="import_all" string="Import" type="object" icon="terp-camera_test"/>
+			                 </group>			                         	
+						 </page>
+      	               	 <page string="Advanced">
+	                   		<field name="email_from" widget="email" colspan="4"/>
+	                   		<separator string="Multi Instance Management" colspan="4"/>
+                         	<field name="instance_name" colspan="4"/>
+	                   		<separator string="Scheduler Paramers:" colspan="4"/>
+	                        <field name="interval_number" colspan="4"/>
+	                        <field name="interval_type"/>
+	                        <field name="nextcall"/>
+	                        <field name="numbercall"/>
+	                        <field name="doall"/>
+		                    <separator string="Technical Data" colspan="4"/>
+	                        <field name="model"/>
+	                        <field name="function"/>
+	                        <separator string="" colspan="4" />
+	                        <group colspan="4">
+	                        	<label string=" " colspan="2"/>
+	                        	<button name="import_from_scheduler_all" string="Scheduler" type="object" icon="" colspan="2"/>
+	                        </group>	
+	                     </page>
+	                  </notebook>
+				 </group>        	                   
+                </form>
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="view_import_sugarcrm_file_data_form">
+            <field name="name">import.sugarcrm.file.form</field>
+            <field name="model">import.sugarcrm</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Import SugarCRM">
+                    <group colspan="4" width="750">
+                         <separator string="Upload Your File:" colspan="4"/>
+							<field name="file"/>
+                         	<notebook colspan="4">
+	                         	<page string="Module To Import">
+	                         	<separator string="Data To Import" colspan="4"/>
+		                         	<field name="opportunity" />
+		                         	<field name= "meeting" />
+		                         	<field name= "task" string="Meeting Tasks"/>
+		                         	<field name= "call" />
+		                         	<field name= "claim" />
+			                         <field name= "account" />
+			                         <field name= "contact" />
+			                         <field name="user" />
+			                         <field name= "employee" />
+			                         <field name= "email" />
+			                         <field name= "project" />
+			                         <field name= "project_task" />
+			                         <field name= "bug" string="Project Issue"/>
+			                         <field name= "document" />
+			                         <field name= "attachment" string="History and Attachment" />	
+			                        <separator string="" colspan="4" />
+			                    	<group colspan="4" >
+				                        <label string="" colspan="2"/>
+				                        <button  icon="gtk-cancel" special="cancel" string="_Cancel"/>
+				                        <button name="import_all" string="Import"
+				                                type="object" icon="terp-camera_test"/>
+			                   		</group>			                                                  	
+	                         	</page>
+	                         	<page string="Advanced">
+	                         		<field name="email_from" widget="email"/>
+	                         		<separator string="Multi Instance Management" colspan="4"/>
+	                         		<field name="instance_name"/>
+	                         	</page>
+                         	</notebook>                         
                     </group>
-                        <separator string="" colspan="4" />
-                    <group colspan="4" >
-                        <label string="" colspan="2"/>
-                        <button  icon="gtk-cancel" special="cancel" string="_Cancel"/>
-                        <button name="import_all" string="Import"
-                                type="object" icon="terp-camera_test"/>
-                   </group>
                 </form>
             </field>
         </record>
 
-        <!-- Import Sugarcrm Action -->
-
-    <record model="ir.actions.act_window" id="action_import_sugarcrm">
-        <field name="name">Import SugarCRM</field>
-        <field name="res_model">import.sugarcrm</field>
-        <field name="view_type">form</field>
-        <field name="view_mode">tree,form</field>
-        <field name="view_id" ref="view_import_sugarcrm_form"/>
-        <field name="target">new</field>
-    </record>
-
-
     </data>
 </openerp>
 

=== modified file 'import_sugarcrm/wizard/__init__.py'
--- import_sugarcrm/wizard/__init__.py	2011-02-17 11:07:49 +0000
+++ import_sugarcrm/wizard/__init__.py	2011-05-04 12:52:28 +0000
@@ -18,6 +18,6 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-
-import sugarcrm_login
 import import_message
+import import_sugarcrm_select_services
+import sugarcrm_login
\ No newline at end of file

=== modified file 'import_sugarcrm/wizard/import_message.py'
--- import_sugarcrm/wizard/import_message.py	2011-02-17 11:07:49 +0000
+++ import_sugarcrm/wizard/import_message.py	2011-05-04 12:52:28 +0000
@@ -25,5 +25,18 @@
 
      _name = "import.message"
      _description = __doc__
+     _columns = {
+        'message': fields.text('Message', readonly=True),
+     }  
+
+     def data_get(self, cr, uid, message, context=None):
+        return {'message': message}
+
+     def default_get(self, cr, uid, fields, context=None):
+        res = {} 
+        if context.get('msg'):
+            data = self.data_get(cr, uid, context.get('msg'), context)
+            res.update(data)
+        return res
      
 import_message()

=== modified file 'import_sugarcrm/wizard/import_message_view.xml'
--- import_sugarcrm/wizard/import_message_view.xml	2011-02-17 11:07:49 +0000
+++ import_sugarcrm/wizard/import_message_view.xml	2011-05-04 12:52:28 +0000
@@ -9,10 +9,14 @@
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Import Message">
-                   <label string="Import Data Successfully" colspan="4"/>  
-                   <separator string="" colspan="4" />
-                   <label string="" colspan="2"/>
-                   <button  icon="gtk-ok" special="cancel" string="_Ok"/>
+                <group colspan="4" width="500">	
+                   <field name="message" nolabel="1" colspan="4"/>
+                 </group>  
+                 <separator string="" colspan="4" />
+                 <group colspan="4">
+                 <label string="" colspan="2"/>
+                 <button  icon="gtk-ok" special="cancel" string="_Ok"/>
+                 </group>
                 </form>
             </field>
         </record>

=== added file 'import_sugarcrm/wizard/import_sugarcrm_select_services.py'
--- import_sugarcrm/wizard/import_sugarcrm_select_services.py	1970-01-01 00:00:00 +0000
+++ import_sugarcrm/wizard/import_sugarcrm_select_services.py	2011-05-04 12:52:28 +0000
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields, osv
+
+class import_sugarcrm_select_services(osv.osv):
+     """Select Services"""
+
+     _name = "import.sugarcrm.select.services"
+     _description = __doc__
+     _columns ={
+              'case': fields.selection([('file','File'), ('service','Web Services')], 'Import From:', size=32, required=True, help="Select Service From which You want to Import data, either From File or Using Web Services"),                
+     }
+                  
+     def open_import(self, cr, uid, ids, context=None):
+        obj_model = self.pool.get('ir.ui.view')
+        val = {}
+        for current in self.browse(cr, uid, ids, context):
+            if current.case == 'file':
+                view_ids = obj_model.search(cr,uid,[('model','=','import.sugarcrm'),('name','=','import.sugarcrm.file.form')])
+                val =  {
+                    'view_type': 'form',
+                    'view_mode': 'form',
+                    'res_model': 'import.sugarcrm',
+                    'views': [(view_ids[0],'form')],
+                    'type': 'ir.actions.act_window',
+                    'target': 'new',
+                }
+            else:
+                view_ids = obj_model.search(cr,uid,[('model','=','import.sugarcrm'),('name','=','import.sugarcrm.webservice.form')])
+                val = {
+                    'view_type': 'form',
+                    'view_mode': 'form',
+                    'res_model': 'import.sugarcrm',
+                    'views': [( view_ids[0],'form')],
+                    'type': 'ir.actions.act_window',
+                    'target': 'new',
+                }
+        return val
+                             
+import_sugarcrm_select_services()

=== added file 'import_sugarcrm/wizard/import_sugarcrm_select_services_view.xml'
--- import_sugarcrm/wizard/import_sugarcrm_select_services_view.xml	1970-01-01 00:00:00 +0000
+++ import_sugarcrm/wizard/import_sugarcrm_select_services_view.xml	2011-05-04 12:52:28 +0000
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+    <!-- Selection Services Wizard -->
+        <record model="ir.ui.view" id="view_import_sugarcrm_select_services_form">
+            <field name="name">import.sugarcrm.selection.services.form</field>
+            <field name="model">import.sugarcrm.select.services</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Import Data From Selected Services">
+                   <group colspan="4" width="450">
+                   <separator string="Select Service" colspan="4" />
+                    <field colspan="4" name="case"/>
+				   </group>	  
+					<separator string="" colspan="4" />				                     
+                   <button  icon="gtk-ok" special="cancel" string="_Close"/>
+                   <button name="open_import" string="_Ok"
+                                type="object" icon="terp-camera_test"/>
+                </form>
+            </field>
+        </record>
+
+    <record model="ir.actions.act_window" id="action_import_sugarcrm_select_services">
+        <field name="name">Import sugarcrm select services wizard </field>
+        <field name="res_model">import.sugarcrm.select.services</field>
+        <field name="view_type">form</field>
+        <field name="view_mode">tree,form</field>
+        <field name="view_id" ref="view_import_sugarcrm_select_services_form"/>
+        <field name="target">new</field>
+    </record>
+
+    <menuitem name="SugarCRM"  id="menu_sugarcrm" parent="base.menu_base_partner"/>
+    <menuitem name="Import SugarCRM" id="menu_sugarcrm_login" parent="menu_sugarcrm" action="action_import_sugarcrm_select_services" icon="STOCK_EXECUTE"/>
+    
+    </data>
+</openerp>   
\ No newline at end of file

=== modified file 'import_sugarcrm/wizard/sugarcrm_login_view.xml'
--- import_sugarcrm/wizard/sugarcrm_login_view.xml	2011-04-14 12:51:54 +0000
+++ import_sugarcrm/wizard/sugarcrm_login_view.xml	2011-05-04 12:52:28 +0000
@@ -26,21 +26,6 @@
                 </form>
             </field>
         </record>
-
-        <!-- Sugarcrm Login Action -->
-
-    <record model="ir.actions.act_window" id="action_sugarcrm_login">
-        <field name="name">SugarCRM Login</field>
-        <field name="res_model">sugarcrm.login</field>
-        <field name="view_type">form</field>
-        <field name="view_mode">tree,form</field>
-        <field name="view_id" ref="view_sugarcrm_login_form"/>
-        <field name="target">new</field>
-    </record>
-
-    <menuitem name="SugarCRM"  id="menu_sugarcrm" parent="base.menu_base_partner"/>
-    <menuitem name="Import SugarCRM" id="menu_sugarcrm_login" parent="menu_sugarcrm" action="action_sugarcrm_login" icon="STOCK_EXECUTE"/>
-
     </data>
 </openerp>
 


Follow ups