[MERGE] backlog 10 by atp team

bzr revid: tfr@openerp.com-20110630122124-1ogmdnigmv5bigu5
This commit is contained in:
tfr@openerp.com 2011-06-30 14:21:24 +02:00
commit 53c194642f
4 changed files with 56 additions and 15 deletions

View File

@ -32,6 +32,7 @@ class crm_installer(osv.osv_memory):
'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_caldav': fields.boolean('Calendar Synchronizing', help="Helps you to synchronize the meetings with other calendar clients and mobiles."),
'import_sugarcrm': fields.boolean('Import SugarCRM', help="Helps you to Integration of SugarCRM data to OpenERP Modules."),
'sale_crm': fields.boolean('Opportunity to Quotation', help="This module relates sale from opportunity cases in the CRM."),
'fetchmail': fields.boolean('Fetch Emails', help="Allows you to receive E-Mails from POP/IMAP server."),
'thunderbird': fields.boolean('Thunderbird', help="Allows you to link your e-mail to OpenERP's documents. You can attach it to any existing one in OpenERP or create a new one."),

View File

@ -36,6 +36,7 @@
<group colspan="2" col="2">
<separator string="Synchronization" colspan="4" />
<field name="crm_caldav" />
<field name="import_sugarcrm"/>
<field name="fetchmail" />
</group>
<group colspan="2" col="2">

View File

@ -60,7 +60,7 @@ class sugar_import(import_framework):
TABLE_NOTE = 'Notes'
TABLE_EMAIL = 'Emails'
TABLE_COMPAIGN = 'Campaigns'
TABLE_DOCUMENT = 'DocumentRevisions'
TABLE_DOCUMENT = 'Documents'
TABLE_HISTORY_ATTACHMNET = 'history_attachment'
MAX_RESULT_PER_PAGE = 200
@ -130,21 +130,52 @@ class sugar_import(import_framework):
import Documents
"""
def import_related_document(self, val):
res_model = False
res_id = False
sugar_document_account = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module='Accounts', query=None, deleted=None)
sugar_document_contact = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_CONTACT, query=None, deleted=None)
sugar_document_opportunity = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_OPPORTUNITY, query=None, deleted=None)
sugar_document_case = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_CASE, query=None, deleted=None)
sugar_document_bug = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_BUG, query=None, deleted=None)
if sugar_document_account:
res_id = self.get_mapped_id(self.TABLE_ACCOUNT,sugar_document_account[0])
res_model = 'res.partner'
elif sugar_document_contact:
res_id = self.get_mapped_id(self.TABLE_CONTACT, sugar_document_contact[0])
res_model = 'res.partner.address'
elif sugar_document_opportunity:
res_id = self.get_mapped_id(self.TABLE_OPPORTUNITY, sugar_document_opportunity[0])
res_model = 'crm.lead'
elif sugar_document_case:
res_id = self.get_mapped_id(self.TABLE_CASE, sugar_document_case[0])
res_model = 'crm.claim'
elif sugar_document_bug:
res_id = self.get_mapped_id(self.TABLE_BUG, sugar_document_bug[0])
res_model = 'project.issue'
return res_id,res_model
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'] = File
val['datas_fname'] = Filename
File,Filename = sugar.get_document_revision_search(self.context.get('port'), self.context.get('session_id'), val.get('document_revision_id'))
res_id, res_model = self.import_related_document(val)
val['res_id'] = res_id
val['res_model'] = res_model
if File:
val['datas'] = File
val['datas_fname'] = Filename
return val
def get_document_mapping(self):
return {
'model' : 'ir.attachment',
'dependencies' : [self.TABLE_USER],
'dependencies' : [self.TABLE_USER, self.TABLE_ACCOUNT,self.TABLE_CONTACT, self.TABLE_OPPORTUNITY, self.TABLE_CASE, self.TABLE_BUG],
'hook' : self.import_document,
'map' : {'name':'filename',
'map' : {'name':'document_name',
'description': ppconcat('description'),
'datas': 'datas',
'datas_fname': 'datas_fname',
'res_model': 'res_model',
'res_id': 'res_id',
}
}
@ -900,7 +931,6 @@ class import_sugarcrm(osv.osv):
'password': fields.char('Password', size=24,required=True),
'url' : fields.char('SugarSoap Api url:', size=264, required=True, help="Webservice's url where to get the data.\
example : 'http://example.com/sugarcrm/soap.php', or copy the address of your sugarcrm application http://trial.sugarcrm.com/qbquyj4802/index.php?module=Home&action=index"),
'opportunity': fields.boolean('Leads and Opportunities', help="If Opportunities are checked, SugarCRM opportunities data imported in OpenERP crm-Opportunity form"),
'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"),
@ -915,8 +945,11 @@ class import_sugarcrm(osv.osv):
'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."),
}
def _get_email_id(self, cr, uid, context=None):
return self.pool.get('res.users').browse(cr, uid, uid, context=context).user_email
_defaults = {#to be set to true, but easier for debugging
'opportunity': True,
'contact' : True,
@ -931,7 +964,7 @@ class import_sugarcrm(osv.osv):
'bug': True,
'document': False,
'instance_name': 'sugarcrm',
'email_from': 'tfr@openerp.com',
'email_from': _get_email_id,
'username' : 'tfr',
'password' : 'a',
'url': "http://localhost/sugarcrm/soap.php"
@ -1005,7 +1038,7 @@ class import_sugarcrm(osv.osv):
if current.bug:
key_list.append('Bugs')
if current.document:
key_list.append('DocumentRevisions')
key_list.append('Documents')
return key_list

View File

@ -11,12 +11,18 @@
<form string="Import Data From SugarCRM">
<group col="8" >
<group colspan="2" col="1" width="200">
<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" string="Import your data from SugarCRM :"/>
<label colspan="2" string="" />
<label colspan="2" string="Use the SugarSoap API URL (read tooltip), a full access Sugar login."/>
<label colspan="2" string="" />
<label colspan="2" string="Choose groups of data you want to import. Click 'Import' to get data manually or click 'schedule reccurent import' to get recurrently and automatically data."/>
<label colspan="2" string="" />
<label colspan="2" string="If you make recurrent or ponctual import, data already imported in OpenERP will be erased by Sugar data."/>
<label colspan="2" string="" />
<label colspan="2" string="Don't forget to add an address email to be notified of the success of the import."/>
<label colspan="2" />
<label colspan="2" string="Here is Document links:"/>
<label colspan="2" string="doc.openerp.com"/>
<label colspan="2" string="Online documentation:"/>
<label colspan="2" string="(Comming Soon)"/>
<label colspan="2" string=""/>
</group>
<separator string="" orientation="vertical" colspan="1" rowspan="24" />