Jigar Amin  (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-import_salesforce-query_bug_fix-jam 
into lp:~openerp-dev/openobject-addons/trunk-import_salesforce.

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

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_salesforce-query_bug_fix-jam/+merge/67117

Changes:
  1) Removed Query problrm for employee
  2) Cleaned the Unused print statements and improved code usability
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_salesforce-query_bug_fix-jam/+merge/67117
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-import_salesforce.
=== modified file 'import_salesforce/wizard/import_salesforce.py'
--- import_salesforce/wizard/import_salesforce.py	2011-07-07 05:15:17 +0000
+++ import_salesforce/wizard/import_salesforce.py	2011-07-07 06:03:27 +0000
@@ -57,7 +57,7 @@
     TABLE_HRDEPT = 'hr.department'
     TABLE_ACCOUNT = "Account"
     DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
-    
+
     object_description = {}
     prefix_table = {}
 
@@ -67,11 +67,9 @@
         #login
         self._SFCLIENT = beatbox.PythonClient()
         self._SFCLIENT.login(self.context.get('username', False),
-                                        self.context.get('passtoken', False))
+                             self.context.get('passtoken', False))
         self.initialize_object_description()
-        
-        
-            
+
     def initialize_object_description(self):
         max_result = 75
         offset = 0
@@ -79,24 +77,21 @@
         while dg['types'][offset:offset+max_result]:
             for tp in self._SFCLIENT.describeSObjects(dg['types'][offset:offset+max_result]):
                 self.object_description[tp.name] = tp
-                if tp.name == self.TABLE_FOLDER:
-                    pp.pprint(tp.fields)
                 self.prefix_table[tp.keyPrefix] = tp.name
             offset+=max_result
-        
 
     def get_where_clause(self, table):
         where_clause = {
             self.TABLE_FOLDER: " WHERE Type = 'Document'",
         }
         return where_clause.get(table, '')
-    
+
     def get_salesforce_table(self, table):
         """
-            Can be use for email, the table email are task actually but with a different where clause 
+        Can be use for email, the table email are task actually but with a different where clause.
         """
         mapping = {
-                   #self.TABLE_EMAIL : self.TABLE_TASK
+            self.TABLE_EMPLOYEE: 'User',
         }
         return mapping.get(table, table)
 
@@ -104,7 +99,6 @@
         table_origin = table
         table = self.get_salesforce_table(table)
         sql = "SELECT " + ', '.join(self.object_description[table].fields) + " FROM " + table + self.get_where_clause(table_origin)
-        #print sql # for debugging
         return self._SFCLIENT.query(sql)
 
     def get_mapping(self):
@@ -189,7 +183,7 @@
                     'user_email': 'Email',
                     'context_tz': 'TimeZoneSidKey',
                     'context_lang': 'LocaleSidKey',
-                    'address_id/id' : self.get_user_address,
+                    'address_id/id': self.get_user_address,
                 }
         }
 
@@ -208,8 +202,6 @@
             doc_type = "url"
         return doc_type
 
-    
-
     def get_document_mapping(self):
         return {
             'model': 'ir.attachment',
@@ -226,7 +218,6 @@
                     }
         }
 
-
     def get_status(self, val, status, status_type):
         fields = ['name', 'type']
         name = status_type + '_' + status
@@ -409,9 +400,9 @@
                 address = partner_pool.address_get(self.cr, self.uid, [partner_id], ['contact'])
                 if not address:
                     address = partner_pool.address_get(self.cr, self.uid, [partner_id], ['invoice'])
-                    add_id =  address['invoice']
+                    add_id = address['invoice']
                 elif address:
-                    add_id =  address['contact']
+                    add_id = address['contact']
                 if add_id:
                     address_rec = address_pool.browse(self.cr, self.uid, add_id)
                     val.update({'partner_address_id': add_id,
@@ -545,8 +536,6 @@
                 }
         }
 
-  
-
     def import_attachment(self, val):
         parent = val.get('ParentId')
         if not parent:
@@ -615,11 +604,9 @@
         }
 
     def get_product_category(self, val, name):
-
         fields = ['name']
-        nameid =  'product_category_'+name
         data = [name]
-        return self.import_object(fields, data, self.TABLE_PRODUCTCAT, self.TABLE_PRODUCTCAT, nameid, [('name', 'ilike', name)])
+        return self.import_object(fields, data, self.TABLE_PRODUCTCAT, self.TABLE_PRODUCTCAT, name, [('name', 'ilike', name)])
 
     def get_product(self, val):
         costprice = listprice = 0.00
@@ -651,7 +638,7 @@
                     'list_price': 'ListPrice',
                 }
         }
-    
+
     def import_employee(self, val):
         users_pool = self.obj.pool.get('res.users')
         user = self.xml_id_exist(self.TABLE_USER, val.get('Id'))
@@ -768,8 +755,6 @@
                 }
         }
 
-    # Import Contact
-
     def get_address_vals(self, key, vals):
         address = {
             'contact': {
@@ -783,7 +768,7 @@
                 'email': vals.get('Email', ''),
                 'fax': vals.get('Fax', ''),
                 'function': vals.get('Title', ''),
-                'title': self.get_title(vals ,vals.get('Salutation'), 'contact'),
+                'title': self.get_title(vals, vals.get('Salutation'), 'contact'),
                 'state_id/id': vals.get('MailingState', False),
                 'country_id/id': vals.get('MailingCountry', False),
             },
@@ -798,7 +783,7 @@
                 'email': vals.get('Email', ''),
                 'fax': vals.get('Fax', ''),
                 'function': vals.get('Title', ''),
-                'title': self.get_title(vals ,vals.get('Salutation'), 'contact'),
+                'title': self.get_title(vals, vals.get('Salutation'), 'contact'),
                 'country_id/id': vals.get('OtherCountry', False),
                 'state_id/id': vals.get('OtherState', False),
             },
@@ -855,13 +840,15 @@
                 'address/id': self.get_partner_address,
                 'user_id/id': ref(self.TABLE_USER, 'OwnerId'),
                 'parent_id/id': ref(self.TABLE_ACCOUNT, 'AccountId'),
-                'comment': ppconcat('HomePhone', 'OtherPhone', 'ReportsTo', 'Birthdate', 'AssistantName', 'AssistantPhone', 'Languages__c', 'LeadSource', 'Description')
+                'comment': ppconcat('HomePhone', 'OtherPhone', 'ReportsTo', 'Birthdate', 'AssistantName', 'AssistantPhone', 'Languages__c', 'LeadSource', 'Description'),
                 }
         }
 
     def get_email_subject(self, result):
         return "Your Salesforce's data were successfully imported at %s" % self.date_ended
 
+
+
 class import_salesforce(osv.osv):
     '''
         Model to Select SalesForce Model to be imported

_______________________________________________
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