From 7448b7a20a43cd38cd9fdedec1342c5f66678c51 Mon Sep 17 00:00:00 2001
From: "tfr@openerp.com" <>
Date: Thu, 14 Jul 2011 17:05:12 +0200
Subject: [PATCH] [FIX] Correction by apr
bzr revid: tfr@openerp.com-20110714150512-ck8st077nvdbl2bj
---
addons/crm/crm_installer.py | 2 +-
addons/import_base/import_framework.py | 12 ++++++++++--
addons/import_sugarcrm/import_sugarcrm.py | 16 +++++++---------
addons/import_sugarcrm/sugar.py | 5 +++--
.../wizard/import_message_view.xml | 2 +-
5 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/addons/crm/crm_installer.py b/addons/crm/crm_installer.py
index 8ceb51a97f8..8c52eae8ab6 100644
--- a/addons/crm/crm_installer.py
+++ b/addons/crm/crm_installer.py
@@ -30,7 +30,7 @@ class crm_installer(osv.osv_memory):
'crm_helpdesk': fields.boolean('Helpdesk', help="Manages a Helpdesk service."),
'crm_fundraising': fields.boolean('Fundraising', help="This may help associations in their fundraising process and tracking."),
'crm_claim': fields.boolean('Claims', help="Manages the suppliers and customers claims, including your corrective or preventive actions."),
- 'import_sugarcrm': fields.boolean('Import SugarCRM', help="Helps you to Integration of SugarCRM data to OpenERP Modules."),
+ 'import_sugarcrm': fields.boolean('Import Data from SugarCRM', help="Help you to import and update data from SugarCRM to OpenERP"),
'crm_caldav': fields.boolean('Synchronization: Calendar Synchronizing', help="Helps you to synchronize the meetings with other calendar clients and mobiles."),
'sale_crm': fields.boolean('Opportunity to Quotation', help="This module relates sale from opportunity cases in the CRM."),
'fetchmail': fields.boolean('Synchronization: Fetch Emails', help="Allows you to receive E-Mails from POP/IMAP server."),
diff --git a/addons/import_base/import_framework.py b/addons/import_base/import_framework.py
index a6906a49b69..b558b24696f 100644
--- a/addons/import_base/import_framework.py
+++ b/addons/import_base/import_framework.py
@@ -61,6 +61,7 @@ class import_framework(Thread):
self.email = email_to_notify
self.table_list = []
self.logger = logging.getLogger('import_framework')
+ self.initialize()
"""
Abstract Method to be implemented in
@@ -73,6 +74,13 @@ class import_framework(Thread):
"""
pass
+ def init_run(self):
+ """
+ call after intialize run in the thread, not in the main process
+ TO use for long initialization operation
+ """
+ pass
+
def get_data(self, table):
"""
@return: a list of dictionaries
@@ -367,9 +375,9 @@ class import_framework(Thread):
self.data_started = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.cr = pooler.get_db(self.cr.dbname).cursor()
error = False
+ result = []
try:
- self.initialize()
- result = []
+ self.init_run()
imported = set() #to invoid importing 2 times the sames modules
for table in self.table_list:
to_import = self.get_mapping()[table].get('import', True)
diff --git a/addons/import_sugarcrm/import_sugarcrm.py b/addons/import_sugarcrm/import_sugarcrm.py
index c1c24cdc595..b27748d48be 100644
--- a/addons/import_sugarcrm/import_sugarcrm.py
+++ b/addons/import_sugarcrm/import_sugarcrm.py
@@ -451,7 +451,7 @@ class sugar_import(import_framework):
def import_task(self, val):
date = val.get('date_start') or datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
- val['date'] = ''.joint(date)
+ val['date'] = ''.join(date)
date_deadline = val.get('date_due') or datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
val['date_deadline'] = ''.join(date_deadline)
return val
@@ -626,7 +626,8 @@ class sugar_import(import_framework):
'type' : const('opportunity'),
'categ_id/id': call(self.get_category, 'crm.lead', value('opportunity_type')),
'email_from': 'email_from',
- 'state': map_val('status', self.opp_state) , #TODO
+ 'state': map_val('status', self.opp_state),
+ 'description' : 'description',
}
}
@@ -698,7 +699,7 @@ class sugar_import(import_framework):
'channel_id/id': call(self.get_channel_id, value('lead_source')),
'type_id/id': ref(self.TABLE_COMPAIGN, 'campaign_id'),
'country_id/id': 'country_id/id',
- 'state_id/id': 'state_id/id'
+ 'state_id/id': 'state_id/id',
}
}
@@ -996,12 +997,9 @@ class import_sugarcrm(osv.osv):
'document': True,
'instance_name': 'sugarcrm',
'email_from': _get_email_id,
- #'username' : 'admin',
- #'password' : '',
- #'url': "http://sugarcrm.example.com/soap.php"
- 'username' : 'tfr',
- 'password' : 'a',
- 'url': "http://localhost/sugarcrm/soap.php"
+ 'username' : 'admin',
+ 'password' : '',
+ 'url': "http://sugarcrm.example.com/soap.php"
}
def check_url(self, url, context):
diff --git a/addons/import_sugarcrm/sugar.py b/addons/import_sugarcrm/sugar.py
index 1ce61d27c0c..783878723e9 100644
--- a/addons/import_sugarcrm/sugar.py
+++ b/addons/import_sugarcrm/sugar.py
@@ -30,7 +30,7 @@ from lxml import etree
import tools
import import_sugarcrm
-
+import logging
class LoginError(Exception): pass
@@ -111,7 +111,8 @@ def get_contact_by_email(portType, username, password, email_address=None):
email_list.append(list.Email_address)
return email_list
except Exception,e:
- return 'Exception: %s\n' % (tools.ustr(e))
+ logging.getLogger('sugarcrm_soap').error('Exception: %s\n' % (tools.ustr(e)))
+ return False
def get_document_revision_search(portType, sessionid, module_id=None):
se_req = get_document_revisionRequest()
diff --git a/addons/import_sugarcrm/wizard/import_message_view.xml b/addons/import_sugarcrm/wizard/import_message_view.xml
index 35a414d7259..581d862e408 100644
--- a/addons/import_sugarcrm/wizard/import_message_view.xml
+++ b/addons/import_sugarcrm/wizard/import_message_view.xml
@@ -9,7 +9,7 @@
form