[FIX] Correction by apr

bzr revid: tfr@openerp.com-20110714150512-ck8st077nvdbl2bj
This commit is contained in:
tfr@openerp.com 2011-07-14 17:05:12 +02:00
parent c90a755359
commit 7448b7a20a
5 changed files with 22 additions and 15 deletions

View File

@ -30,7 +30,7 @@ class crm_installer(osv.osv_memory):
'crm_helpdesk': fields.boolean('Helpdesk', help="Manages a Helpdesk service."), '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_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."), '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."), '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."), '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."), 'fetchmail': fields.boolean('Synchronization: Fetch Emails', help="Allows you to receive E-Mails from POP/IMAP server."),

View File

@ -61,6 +61,7 @@ class import_framework(Thread):
self.email = email_to_notify self.email = email_to_notify
self.table_list = [] self.table_list = []
self.logger = logging.getLogger('import_framework') self.logger = logging.getLogger('import_framework')
self.initialize()
""" """
Abstract Method to be implemented in Abstract Method to be implemented in
@ -73,6 +74,13 @@ class import_framework(Thread):
""" """
pass 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): def get_data(self, table):
""" """
@return: a list of dictionaries @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.data_started = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.cr = pooler.get_db(self.cr.dbname).cursor() self.cr = pooler.get_db(self.cr.dbname).cursor()
error = False error = False
result = []
try: try:
self.initialize() self.init_run()
result = []
imported = set() #to invoid importing 2 times the sames modules imported = set() #to invoid importing 2 times the sames modules
for table in self.table_list: for table in self.table_list:
to_import = self.get_mapping()[table].get('import', True) to_import = self.get_mapping()[table].get('import', True)

View File

@ -451,7 +451,7 @@ class sugar_import(import_framework):
def import_task(self, val): def import_task(self, val):
date = val.get('date_start') or datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 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'), date_deadline = val.get('date_due') or datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
val['date_deadline'] = ''.join(date_deadline) val['date_deadline'] = ''.join(date_deadline)
return val return val
@ -626,7 +626,8 @@ class sugar_import(import_framework):
'type' : const('opportunity'), 'type' : const('opportunity'),
'categ_id/id': call(self.get_category, 'crm.lead', value('opportunity_type')), 'categ_id/id': call(self.get_category, 'crm.lead', value('opportunity_type')),
'email_from': 'email_from', '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')), 'channel_id/id': call(self.get_channel_id, value('lead_source')),
'type_id/id': ref(self.TABLE_COMPAIGN, 'campaign_id'), 'type_id/id': ref(self.TABLE_COMPAIGN, 'campaign_id'),
'country_id/id': 'country_id/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, 'document': True,
'instance_name': 'sugarcrm', 'instance_name': 'sugarcrm',
'email_from': _get_email_id, 'email_from': _get_email_id,
#'username' : 'admin', 'username' : 'admin',
#'password' : '', 'password' : '',
#'url': "http://sugarcrm.example.com/soap.php" 'url': "http://sugarcrm.example.com/soap.php"
'username' : 'tfr',
'password' : 'a',
'url': "http://localhost/sugarcrm/soap.php"
} }
def check_url(self, url, context): def check_url(self, url, context):

View File

@ -30,7 +30,7 @@ from lxml import etree
import tools import tools
import import_sugarcrm import import_sugarcrm
import logging
class LoginError(Exception): pass 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) email_list.append(list.Email_address)
return email_list return email_list
except Exception,e: 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): def get_document_revision_search(portType, sessionid, module_id=None):
se_req = get_document_revisionRequest() se_req = get_document_revisionRequest()

View File

@ -9,7 +9,7 @@
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Import Message"> <form string="Import Message">
<label colspan="4" nolabel="1" string="Data are importing, the process is running in the background, you will receive an email at the end of the import."/> <label colspan="4" nolabel="1" string="Data are importing, the process is running in the background, an email will be sent to the given email address if it was defined."/>
<separator string="" colspan="4" /> <separator string="" colspan="4" />
<button icon="gtk-ok" special="cancel" string="_Ok"/> <button icon="gtk-ok" special="cancel" string="_Ok"/>
</form> </form>