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

Requested reviews:
  tfr (Openerp) (tfr)

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

Hello,

I had done backlog: 3.4:
http://pad.openerp.com/rd-v61-tfr-import-sugarcrm

Kidnly review it.



Thanks
Atul
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_sugarcrm-backlog_3.4-atp/+merge/63520
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-import_sugarcrm.
=== added directory 'import_sugarcrm/doc'
=== added file 'import_sugarcrm/doc/Installation Guidline For SugarCRM.doc'
Binary files import_sugarcrm/doc/Installation Guidline For SugarCRM.doc	1970-01-01 00:00:00 +0000 and import_sugarcrm/doc/Installation Guidline For SugarCRM.doc	2011-06-06 06:38:25 +0000 differ
=== modified file 'import_sugarcrm/import_sugarcrm.py'
--- import_sugarcrm/import_sugarcrm.py	2011-05-30 16:59:08 +0000
+++ import_sugarcrm/import_sugarcrm.py	2011-06-06 06:38:25 +0000
@@ -60,6 +60,7 @@
     TABLE_NOTE = 'Notes'
     TABLE_EMAIL = 'Emails'
     TABLE_COMPAIGN = 'Campaigns'
+    TABLE_DOCUMENT = 'DocumentRevisions'
     TABLE_HISTORY_ATTACHMNET = 'history_attachment'
     
     def initialize(self):
@@ -71,7 +72,7 @@
         self.context['session_id'] = sessionid
         
     def get_data(self, table):
-        return sugar.search(self.context.get('port'), self.context.get('session_id'), table)
+          return sugar.search(self.context.get('port'), self.context.get('session_id'), table, 0, 500)
     """
     Common import method
     """
@@ -112,6 +113,29 @@
         return "%s.%i" % (hour, min)
     
     """
+    import Documents
+    """
+    
+    def import_document(self, val):
+        File,Filename = sugar.get_document_revision_search(self.context.get('port'), self.context.get('session_id'), val.get('id'))
+        val['datas'] = base64.encodestring(File)
+        val['datas_fname'] = Filename
+        return val   
+        
+    def get_document_mapping(self): 
+        return { 
+                'model' : 'ir.attachment',
+                'dependencies' : [self.TABLE_USER],
+                'hook' : self.import_document,
+                'map' : {'name':'filename',
+                         'description': ppconcat('description'),
+                         'datas': 'datas',
+                         'datas_fname': 'datas_fname',
+                }
+            }     
+        
+    
+    """
     import Emails
     """
 
@@ -126,16 +150,18 @@
         return attach_xml_id
     
     def import_email(self, val):
+        vals = sugar.email_search(self.context.get('port'), self.context.get('session_id'), self.TABLE_EMAIL, val.get('id'))
         model_obj =  self.obj.pool.get('ir.model.data')
-        xml_id = self.xml_id_exist(val.get('parent_type'), val.get('parent_id'))
-        model_ids = model_obj.search(self.cr, self.uid, [('name', 'like', xml_id)])
-        if model_ids:
-            model = model_obj.browse(self.cr, self.uid, model_ids)[0]
-            if model.model == 'res.partner':
-                val['partner_id/.id'] = model.res_id
-            else:    
-                val['res_id'] = model.res_id
-                val['model'] = model.model
+        for val in vals:
+            xml_id = self.xml_id_exist(val.get('parent_type'), val.get('parent_id'))
+            model_ids = model_obj.search(self.cr, self.uid, [('name', 'like', xml_id)])
+            if model_ids:
+                model = model_obj.browse(self.cr, self.uid, model_ids)[0]
+                if model.model == 'res.partner':
+                    val['partner_id/.id'] = model.res_id
+                else:    
+                    val['res_id'] = model.res_id
+                    val['model'] = model.model
         return val   
         
     def get_email_mapping(self): 
@@ -147,7 +173,7 @@
                          'history' : const("1"),
                         'date':'date_sent',
                         'email_from': 'from_addr_name',
-                        'email_to': 'reply_to_addr',
+                        'email_to': 'to_addrs_names',
                         'email_cc': 'cc_addrs_names',
                         'email_bcc': 'bcc_addrs_names',
                         'message_id': 'message_id',
@@ -248,6 +274,7 @@
                     'description': ppconcat('description', 'resolution', 'work_log'),
                     'partner_id/id': ref(self.TABLE_ACCOUNT, 'account_id'),
                     'partner_address_id/.id': 'partner_address_id/.id',
+                    'categ_id/id': call(self.get_category, 'crm.claim', value('type')),
                     'partner_phone': 'partner_phone',
                     'email_from': 'email_from',                                        
                     'priority': self.get_claim_priority,
@@ -593,7 +620,6 @@
         'Dead': 'done',
         'Converted': 'done',
     }
-
     
     def import_lead(self, val):
         if val.get('opportunity_id'): #if lead is converted into opp, don't import as lead
@@ -640,6 +666,12 @@
     """
         import contact
     """
+    
+    def get_email(self, val):
+        email_address = sugar.get_contact_by_email(self.context.get('port'), self.context.get('username'), self.context.get('password'), val.get('email1'))
+        if email_address:
+            return ','.join(email_address)     
+    
     def import_contact(self, val):
         if val.get('primary_address_country'):
             country_id = self.get_all_countries(val.get('primary_address_country'))
@@ -665,7 +697,7 @@
                 'city': 'primary_address_city',
                 'country_id/id': 'country_id/id',
                 'state_id/id': 'state_id/id',
-                'email': concat('email1', 'email2', delimiter=','),
+                'email': self.get_email,
                 'type': const('contact')
             }
         }
@@ -673,37 +705,46 @@
     """ 
         import Account
     """
+    
     def get_address_type(self, val, type):
         if type == 'invoice':
             type_address = 'billing'
         else:
-            type_address = 'shipping'     
-    
-        map_partner_address = {
+            type_address = 'shipping' 
+            
+        if type == 'default':
+             map_partner_address = {
             'name': 'name',
-            'phone': 'phone_office',
-            'mobile': 'phone_mobile',
-            'fax': 'phone_fax',
-            'type': 'type',
-            'street': type_address + '_address_street',
-            'zip': type_address +'_address_postalcode',
-            'city': type_address +'_address_city',
-             'country_id/id': 'country_id/id',
-             'type': 'type',
+            'type': const('default'),
+            'email': 'email1' 
             }
-        
+        else:        
+            map_partner_address = {
+                'name': 'name',
+                'phone': 'phone_office',
+                'mobile': 'phone_mobile',
+                'fax': 'phone_fax',
+                'type': 'type',
+                'street': type_address + '_address_street',
+                'zip': type_address +'_address_postalcode',
+                'city': type_address +'_address_city',
+                 'country_id/id': 'country_id/id',
+                 'type': 'type',
+                }
+            
         if val.get(type_address +'_address_country'):
             country_id = self.get_all_countries(val.get(type_address +'_address_country'))
             state = self.get_all_states(val.get(type_address +'_address_state'), country_id)
             val['country_id/id'] =  country_id
             val['state_id/id'] =  state
+            
         val['type'] = type
         val['id_new'] = val['id'] + '_address_' + type
         return self.import_object_mapping(map_partner_address, val, 'res.partner.address', self.TABLE_CONTACT, val['id_new'], self.DO_NOT_FIND_DOMAIN) 
-    
+        
     def get_partner_address(self, val):
         address_id=[]
-        type_dict = {'billing_address_street' : 'invoice', 'shipping_address_street' : 'delivery'}
+        type_dict = {'billing_address_street' : 'invoice', 'shipping_address_street' : 'delivery', 'type': 'default'}
         for key, type_value in type_dict.items():
             if val.get(key):
                 id = self.get_address_type(val, type_value)
@@ -838,6 +879,7 @@
             self.TABLE_CASE: self.get_crm_claim_mapping(),
             self.TABLE_NOTE: self.get_history_mapping(),
             self.TABLE_EMAIL: self.get_email_mapping(),
+            self.TABLE_DOCUMENT: self.get_document_mapping(),
             self.TABLE_COMPAIGN: self.get_compaign_mapping()
         }
         
@@ -873,6 +915,7 @@
         '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"),
         'bug': fields.boolean('Bugs', help="If Bugs is checked, SugarCRM Bugs data imported in OpenERP Project Issues form"),
+        'document': fields.boolean('Documents', help="If Documents is checked, SugarCRM Documents data imported in OpenERP Document Form"),
         'email_from': fields.char('Notify End Of Import To:', size=128),
         '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."),
         
@@ -889,6 +932,7 @@
         'project' : False,   
         'project_task': False,     
         'bug': False,
+        'document': False,
         'instance_name': 'sugarcrm',
         'email_from': '[email protected]',
         'username' : 'tfr',
@@ -963,6 +1007,8 @@
                 key_list.append('ProjectTask')
             if current.bug:
                 key_list.append('Bugs')
+            if current.document:
+                key_list.append('DocumentRevisions')
         return key_list
 
 
@@ -994,7 +1040,6 @@
         }
     
     
-    
     def import_all(self, cr, uid, ids, context=None):
         
 #        """Import all sugarcrm data into openerp module"""

=== modified file 'import_sugarcrm/import_sugarcrm_view.xml'
--- import_sugarcrm/import_sugarcrm_view.xml	2011-05-30 11:09:01 +0000
+++ import_sugarcrm/import_sugarcrm_view.xml	2011-06-06 06:38:25 +0000
@@ -9,59 +9,72 @@
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Import Data From SugarCRM">
-                    <group colspan="4" width="800">
-                    	<separator string="Login Information" colspan="4"/>
-                    	 <field name="url" colspan="4" widget="url"/>
-                         <field name="username"/>
-                         <newline/>
-                         <field name="password" password="True" />
-                         <separator string="" colspan="4"/>
-                         <group colspan="4" col="6">
-                            <group colspan="1" col="2">    
-                                <separator string="Address Book" colspan="4"/>
-                                <field name= "account" />
-                                <field name= "contact" />
-                            </group>                         
-                            <group colspan="3" col="4">    
-                                <separator string="CRM" colspan="4"/>
-                             	<field name="opportunity" />
-                             	<field name= "meeting" />
-                             	<field name= "call" />
-                             	<field name= "claim" />
-                             </group>
-                             <group colspan="2" col="2"> 
-                                <separator string="Project" colspan="4"/>       
-	                             <field name= "project" />
-	                             <field name= "project_task" />
-	                             <field name= "bug"/>
-                            </group>
-                            <group colspan="1" col="2">
-                                <separator string="HR" colspan="4"/>
-    	                         <field name="employee" />  
-                            </group>   
-                            <group colspan="2" col="4">
-                                <separator string="Document" colspan="4"/>
-                                <field name="email_history"/>
-                            </group>
-                          </group>  
-	                         <group colspan="4">
-	                         	<separator string="Email Notification When Import is finished" colspan="4"/>
-	                     		<field name="email_from" widget="email" string="Email Address to Notify"/>
-	                     	</group>
-	                     	<group colspan="4" groups="base.group_no_one">   
-	                   			<separator string="Multi Instance Management" colspan="4"/>
-	                       		<field name="instance_name"/>
-	                       </group>
-                    </group>
-                        <separator string="" colspan="4" />
-                    <group colspan="4" col="6">
-                        <label string="" colspan="2"/>
-                        <button  icon="gtk-cancel" special="cancel" string="_Cancel"/>
-                         <button name="import_from_scheduler_all" string="_Schedule recurrent import"
-                                   type="object" icon="gtk-execute"/>
-                        <button name="import_all" string="_Import"
-                                type="object" icon="terp-camera_test"/>
-                   </group>
+    				<group col="8" width="980">
+	    				<group colspan="2" col="1">
+	    					<label colspan="1"  string=""/>
+	    					<label colspan="2"  string="Explaination Text"/>
+	    					<label colspan="1"  string="This Module Import SugarCRM Module Data into OpenERP Module."/>
+	    					<label colspan="2" />
+	    	                <label colspan="2"  string="Here is Document links:"/>
+                            <label colspan="2"  string="doc.openerp.com"/>
+                            <label colspan="2"  string=""/>
+			            </group>
+	    				<separator string="" orientation="vertical" colspan="1" rowspan="24" />                
+	                    <group colspan="4">
+	                    	<separator string="Login Information" colspan="3"/>
+	                    	 <field name="url" colspan="4" widget="url"/>
+	                         <field name="username"/>
+	                         <newline/>
+	                         <field name="password" password="True" />
+	                         <separator string="" colspan="4"/>
+	                         <group colspan="4" col="6">
+	                            <group colspan="1" col="2">    
+	                                <separator string="Address Book" colspan="4"/>
+	                                <field name= "account" />
+	                                <field name= "contact" />
+	                            </group>                         
+	                            <group colspan="1" col="1">    
+	                                <separator string="CRM" colspan="4"/>
+	                             	<field name="opportunity" />
+	                             	<field name= "call" />
+	                             	<field name= "meeting" />
+	                             	<field name= "claim" />
+	                             	<field name="email_history"/>
+	                             </group>
+	                            <group colspan="1" col="2">
+	                                <separator string="HR" colspan="4"/>
+	    	                         <field name="employee" />  
+	                            </group>   
+	                             <group colspan="2" col="2"> 
+	                                <separator string="Project" colspan="4"/>       
+		                             <field name= "project" />
+		                             <field name= "project_task" />
+		                             <field name= "bug"/>
+	                            </group>
+	                            <group colspan="1" col="4">
+	                                <separator string="Document" colspan="4"/>
+		                             <field name= "document" />
+	                            </group>	                            
+	                          </group>  
+		                         <group colspan="4">
+		                         	<separator string="Email Notification When Import is finished" colspan="4"/>
+		                     		<field name="email_from" widget="email" string="Email Address to Notify"/>
+		                     	</group>
+		                     	<group colspan="4" groups="base.group_no_one">   
+		                   			<separator string="Multi Instance Management" colspan="4"/>
+		                       		<field name="instance_name"/>
+		                       </group>
+	                        <separator string="" colspan="4" />
+	                    <group colspan="4" col="6">
+	                        <label string="" colspan="2"/>
+	                        <button  icon="gtk-cancel" special="cancel" string="_Cancel"/>
+	                         <button name="import_from_scheduler_all" string="_Schedule recurrent import"
+	                                   type="object" icon="gtk-execute"/>
+	                        <button name="import_all" string="_Import"
+	                                type="object" icon="terp-camera_test"/>
+	                   </group>		                       
+	                    </group>
+	                </group>   
                 </form>
             </field>
         </record>

=== modified file 'import_sugarcrm/sugar.py'
--- import_sugarcrm/sugar.py	2011-05-30 16:59:08 +0000
+++ import_sugarcrm/sugar.py	2011-06-06 06:38:25 +0000
@@ -114,10 +114,50 @@
     except Exception,e:
         return 'Exception: %s\n' % (tools.ustr(e))
 
-def search(portType, sessionid, module_name=None):
+def get_document_revision_search(portType, sessionid, module_id=None):
+  se_req = get_document_revisionRequest()
+  se_req._session = sessionid
+  se_req._i = module_id
+  se_resp = portType.get_document_list(se_req)
+  file = False
+  filename = False
+  file = se_resp._return.Document_revision.File
+  filename = se_resp._return.Document_revision.Filename
+  return file, filename
+
+
+def email_search(portType, sessionid, module_name, module_id, select_fields=None):
+  se_req = get_entryRequest()
+  se_req._session = sessionid
+  se_req._module_name = module_name
+  se_req._id = module_id
+  se_req._select_fields = select_fields
+  
+  se_resp = portType.get_entry(se_req)
+  ans_list = []
+  if se_resp:
+      list = se_resp._return._entry_list
+      
+      for i in list:
+          ans_dir = {}
+          for j in i._name_value_list:
+              ans_dir[tools.ustr(j._name)] = tools.ustr(j._value)
+            #end for
+          ans_list.append(ans_dir)
+    #end for
+  return ans_list
+
+def search(portType, sessionid, module_name, offset, max_results, query=None, order_by=None, select_fields=None, deleted=None):
   se_req = get_entry_listRequest()
   se_req._session = sessionid
   se_req._module_name = module_name
+  if query != None:
+      se_req._query = query
+  se_req._order_by = order_by
+  se_req._offset = offset
+  se_req._select_fields = select_fields
+  se_req._max_results = max_results
+  se_req._deleted = deleted
   se_resp = portType.get_entry_list(se_req)
   ans_list = []
   if se_resp:

=== modified file 'import_sugarcrm/sugarsoap_services.py'
--- import_sugarcrm/sugarsoap_services.py	2011-05-30 16:59:08 +0000
+++ import_sugarcrm/sugarsoap_services.py	2011-06-06 06:38:25 +0000
@@ -212,6 +212,18 @@
         response = self.binding.Receive(typecode)
         return response
 
+    #op: get_document_list
+    def get_document_list(self, request):
+        if isinstance(request, get_document_revisionRequest) is False:
+            raise TypeError, "%s incorrect request type" % (request.__class__)
+        kw = {}
+        # no input wsaction
+        self.binding.Send(None, None, request, soapaction="http://"+ IP +"/sugarcrm/soap.php/get_document_list", encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";, **kw)
+        # no output wsaction
+        typecode = Struct(pname=None, ofwhat=get_document_revisionResponse.typecode.ofwhat, pyclass=get_document_revisionResponse.typecode.pyclass)
+        response = self.binding.Receive(typecode)
+        return response    
+
     # op: get_entry_list
     def get_entry_list(self, request):
         if isinstance(request, get_entry_listRequest) is False:
@@ -900,6 +912,22 @@
 get_entriesResponse.typecode.pyclass = get_entriesResponse
 
 _set_entryRequestTypecode = Struct(pname=("http://www.sugarcrm.com/sugarcrm","set_entry";), ofwhat=[ZSI.TC.String(pname="session", aname="_session", typed=False, encoded=None, minOccurs=1, maxOccurs=1, nillable=True), ZSI.TC.String(pname="module_name", aname="_module_name", typed=False, encoded=None, minOccurs=1, maxOccurs=1, nillable=True), ns0.name_value_list_Def(pname="name_value_list", aname="_name_value_list", typed=False, encoded=None, minOccurs=1, maxOccurs=1, nillable=True)], pyclass=None, encoded="http://www.sugarcrm.com/sugarcrm";)
+
+class get_document_revisionRequest:
+    def __init__(self):
+        self._session = None
+        self._i = None
+        return
+get_document_revisionRequest.typecode = Struct(pname=("http://www.sugarcrm.com/sugarcrm","get_document_revision";), ofwhat=[ZSI.TC.String(pname="session", aname="_session", typed=False, encoded=None, minOccurs=1, maxOccurs=1, nillable=True), ZSI.TC.String(pname="i", aname="_i", typed=False, encoded=None, minOccurs=1, maxOccurs=1, nillable=True)], pyclass=get_document_revisionRequest, encoded="http://www.sugarcrm.com/sugarcrm";)
+
+class get_document_revisionResponse:
+    def __init__(self):
+        self._return = None
+        return
+get_document_revisionResponse.typecode = Struct(pname=("http://www.sugarcrm.com/sugarcrm","get_document_revisionResponse";), ofwhat=[ns0.return_document_revision_Def(pname="return", aname="_return", typed=False, encoded=None, minOccurs=1, maxOccurs=1, nillable=True)], pyclass=get_document_revisionResponse, encoded="http://www.sugarcrm.com/sugarcrm";)
+
+
+
 class set_entryRequest:
     typecode = _set_entryRequestTypecode
     __metaclass__ = pyclass_type

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to