Jigar Amin (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-import_salesforce-b9_feeds-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-b9_feeds-jam/+merge/69047
Changes - Chatter : Table FeedItem :
- Import As Messages History
Feed Tables = "AccountFeed", "CaseFeed", "ContactFeed", "ContractFeed",
"EventFeed", "LeadFeed", "OpportunityFeed", "Product2Feed", "TaskFeed",
"UserFeed"
- Added new Web-Services(v21 wsdl) link to access new Object of the FeedItem
Kindly Review This.
Thank You
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-import_salesforce-b9_feeds-jam/+merge/69047
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-25 06:11:17 +0000
+++ import_salesforce/wizard/import_salesforce.py 2011-07-25 09:12:43 +0000
@@ -57,6 +57,18 @@
TABLE_EMPLOYEE = "Employee"
TABLE_PRODUCTCAT = "product.category"
TABLE_HRDEPT = 'hr.department'
+ TABLE_ACCOUNT = "Account"
+ #ItemFeed Tables
+ TABLE_ACCOUNT_FEED = 'AccountFeed'
+ TABLE_CASE_FEED = 'CaseFeed'
+ TABLE_CONTACT_FEED = 'ContactFeed'
+ TABLE_CONTRACT_FEED = 'ContractFeed'
+ TABLE_EVENT_FEED = 'EventFeed'
+ TABLE_LEAD_FEED = 'LeadFeed'
+ TABLE_OPPORTUNITY_FEED = 'OpportunityFeed'
+ TABLE_PRODUCT2_FEED = 'Product2Feed'
+ TABLE_TASK_FEED = 'TaskFeed'
+ TABLE_USER_FEED = 'UserFeed'
TABLE_CONTRACT = 'Contract'
TABLE_ACCOUNT = 'Account'
TABLE_NOTE = 'Note'
@@ -68,8 +80,11 @@
def initialize(self):
#define external id field
self.external_id_field = 'Id'
- #login
self._SFCLIENT = beatbox.PythonClient()
+ #The FeedItem object was introduced in the Spring '11 release of Force.com
+ #So Using Latest version22 webservices wsdl
+ #Here we areusing Partner WebServices
+ self._SFCLIENT.serverUrl="https://login.salesforce.com/services/Soap/u/21.0"
self._SFCLIENT.login(self.context.get('username', False),
self.context.get('passtoken', False))
self.initialize_object_description()
@@ -99,7 +114,7 @@
"""
mapping = {
self.TABLE_EMPLOYEE: 'User',
- self.TABLE_CONVERTEDOPPO : 'Lead',
+ self.TABLE_CONVERTEDOPPO: 'Lead',
self.TABLE_EMAIL: 'Task',
}
return mapping.get(table, table)
@@ -143,6 +158,16 @@
self.TABLE_OPPOHISTORY: self.get_oppo_history_mapping(),
self.TABLE_CONVERTEDOPPO: self.get_convertoppo_mapping(),
self.TABLE_ATTENDEE: self.get_attendee_mapping(),
+ self.TABLE_ACCOUNT_FEED: self.get_feed_mapping(),
+ self.TABLE_CASE_FEED: self.get_feed_mapping(),
+ self.TABLE_CONTACT_FEED: self.get_feed_mapping(),
+ self.TABLE_CONTRACT_FEED: self.get_feed_mapping(),
+ self.TABLE_EVENT_FEED: self.get_feed_mapping(),
+ self.TABLE_LEAD_FEED: self.get_feed_mapping(),
+ self.TABLE_OPPORTUNITY_FEED: self.get_feed_mapping(),
+ self.TABLE_PRODUCT2_FEED: self.get_feed_mapping(),
+ self.TABLE_TASK_FEED: self.get_feed_mapping(),
+ self.TABLE_USER_FEED: self.get_feed_mapping(),
self.TABLE_CONTRACT: self.get_contract_mapping(),
self.TABLE_NOTE: self.get_note_mapping(),
}
@@ -347,11 +372,11 @@
}
def get_convertoppo_mapping(self):
- return{
- 'model': 'crm.lead',
- 'dependencies': [self.TABLE_USER],
- 'hook' : self.import_lead,
- 'map': {
+ return{
+ 'model': 'crm.lead',
+ 'dependencies': [self.TABLE_USER],
+ 'hook': self.import_lead,
+ 'map': {
'name': 'Company',
'user_id/id': ref(self.TABLE_USER, 'CreatedById'),
'state': const('done'),
@@ -370,7 +395,7 @@
'country_id/id': 'country_id/id',
'state_id/id': 'state_id/id',
'channel_id/id': call(self.get_channel, value('LeadSource')),
- 'type' : const('opportunity'),
+ 'type': const('opportunity'),
}
}
@@ -599,7 +624,7 @@
'res_model': 'Model',
'res_id': 'ResourceId',
'description': 'Description',
- 'partner_id/.id' : 'PartnerID',
+ 'partner_id/.id': 'PartnerID',
}
}
@@ -662,7 +687,7 @@
if xmlid and model_map.get('table'):
cid = self.get_mapped_id(table, vals.get('WhatId'))
vals.update({'Model': model_map.get('table'),
- 'ResId': cid })
+ 'ResId': cid})
return vals
def get_email_mapping(self):
@@ -677,7 +702,7 @@
'description': 'Description',
'model': "Model",
'res_id': "ResId",
- 'partner_id/.id': 'PartnerId'
+ 'partner_id/.id': 'PartnerId',
}
}
@@ -883,8 +908,8 @@
'fax': 'fax',
'country_id/id': 'country_id/id',
'state_id/id': 'state_id/id',
- 'function': 'function',
- 'title/id': 'title',
+ 'function': 'function',
+ 'title/id': 'title',
}
for add_type in address_types:
val = self.get_address_vals(add_type, vals)
@@ -912,7 +937,7 @@
'dependencies': [self.TABLE_USER, self.TABLE_ACCOUNT],
'map': {
'name': 'Name',
- 'customer': const('0'),
+ 'customer': const('1'),
'supplier': const('0'),
'title/id': call(self.get_title, value('Title'), const('partner')),
'address/id': self.get_partner_address,
@@ -921,36 +946,76 @@
'comment': ppconcat('HomePhone', 'OtherPhone', 'ReportsTo', 'Birthdate', 'AssistantName', 'AssistantPhone', 'Languages__c', 'LeadSource', 'Description'),
}
}
-
+
+ def get_feed(self, vals):
+ vals.update({'Title': vals.get('Type', "Type")+" : "+vals.get('Title', "No Title")})
+ if vals.get('ParentId'):
+ table = self.prefix_table.get(vals.get('ParentId')[0:3])
+ xmlid = self.xml_id_exist(table, vals.get('ParentId'))
+ if xmlid and table == self.TABLE_CONTACT:
+ cid = self.get_mapped_id(table, vals.get('ParentId'))
+ vals.update({'PartnerId': cid})
+ elif xmlid:
+ vals.update({'Model': self.get_mapping().get(table) and self.get_mapping().get(table).get('model') or False,
+ 'ResourceId': self.get_mapped_id(table, vals.get('ParentId'))})
+ if vals.get('Type') and vals.get('Type') == 'ContentPost':
+ attch_id = []
+ field_map = {'name': 'Name',
+ 'datas': 'Body',
+ 'datas_fname': 'Name'}
+ values = {'Name': vals.get('ContentFileName', ""),
+ 'Body': vals.get("ContentData", False),
+ 'id_new': vals['Id']}
+ attch_id.append(self.import_object_mapping(field_map, values, 'ir.attachment', self.TABLE_ATTACHMENT, values.get('id_new'), self.DO_NOT_FIND_DOMAIN))
+ vals.update({'Attachments': ",".join(attch_id)})
+ return vals
+
+ def get_feed_mapping(self):
+ return {
+ 'model': 'mailgate.message',
+ 'dependencies': [self.TABLE_ACCOUNT, self.TABLE_CONTACT, self.TABLE_MEETING, self.TABLE_LEAD, self.TABLE_CONVERTEDOPPO, self.TABLE_PRODUCT, self.TABLE_TASK, self.TABLE_USER],
+ 'hook': self.get_feed,
+ 'map': {
+ 'name': 'Title',
+ 'user_id/id': ref(self.TABLE_USER, 'CreatedById'),
+ 'date': call(self.get_date, value('CreatedDate')),
+ 'description': ppconcat('ContentType', 'LinkUrl', 'ContentFileName', 'LikeCount', 'ContentDescription', 'CommentCount', 'Body'),
+ 'model': "Model",
+ 'res_id': "ResourceId",
+ 'partner_id/.id': "PartnerId",
+ 'attachment_ids/id': 'Attachments',
+ }
+ }
+
def get_note_mapping(self):
return {
'model': 'mailgate.message',
'dependencies': [self.TABLE_ACCOUNT, self.TABLE_LEAD, self.TABLE_OPPOHISTORY, self.TABLE_CLAIM, self.TABLE_MEETING],
'hook': self.import_attachment,
'map': {
- 'name': 'Title',
- 'user_id/id': ref(self.TABLE_USER, 'OwnerId'),
- 'description': 'Body',
- 'date': call(self.get_date, value('CreatedDate')),
- 'model': 'Model',
- 'res_id': 'ResourceId',
- 'partner_id/.id' : 'PartnerID',
- }
+ 'name': 'Title',
+ 'user_id/id': ref(self.TABLE_USER, 'OwnerId'),
+ 'description': 'Body',
+ 'date': call(self.get_date, value('CreatedDate')),
+ 'model': 'Model',
+ 'res_id': 'ResourceId',
+ 'partner_id/.id': 'PartnerID',
+ }
}
def get_contract(self, vals):
partner_pool = self.obj.pool.get("res.partner")
account = vals.pop('Account', {})
name = vals.get('ContractNumber') + "-" + account.get('Name', "")
- vals.update({'Name':name,
- 'AccountId': account.get('Id', False)})
+ vals.update({'Name': name,
+ 'AccountId': account.get('Id', False)})
if account.get('Id'):
contact = self.xml_id_exist(self.TABLE_ACCOUNT, account.get('Id'))
if contact:
account_id = self.get_mapped_id(self.TABLE_ACCOUNT, account.get('Id'))
account_rec = partner_pool.browse(self.cr, self.uid, account_id, context=self.context)
if account_rec.address:
- types =[ address.type for address in account_rec.address]
+ types = [address.type for address in account_rec.address]
if 'invoice' not in types:
address = {
'partner_id/.id': 'PartnerId',
@@ -990,13 +1055,13 @@
'map': {
'name': 'Name',
'code': 'ContractNumber',
- 'partner_id/id': ref(self.TABLE_ACCOUNT, 'AccountId'),
+ 'partner_id/id': ref(self.TABLE_ACCOUNT, 'AccountId'),
'date': call(self.get_date, value('EndDate')),
'date_start': call(self.get_date, value('StartDate')),
- 'description': ppconcat('CustomerSignedTitle', 'StatusCode', 'SpecialTerms', 'Status', 'ContractTerm', 'OwnerExpirationNotice', 'SystemModstamp', 'Description')
+ 'description': ppconcat('CustomerSignedTitle', 'StatusCode', 'SpecialTerms', 'Status', 'ContractTerm', 'OwnerExpirationNotice', 'SystemModstamp', 'Description'),
}
}
-
+
def get_email_subject(self, result):
return "Your Salesforce's data were successfully imported at %s" % self.date_ended
@@ -1022,6 +1087,7 @@
'product': fields.boolean('Products', help="If Products is checked, SalesFroce Products data imported to OpenERP Products"),
'employee': fields.boolean('Employees', help="If Employees is checked, SalesFroce Per Users Employees will be created"),
'account': fields.boolean('Accounts', help="If Accounts is checked, SalesFroce Accounts details will be imported to the OpenERP Contact."),
+ 'feed': fields.boolean('Feeds/Communication', help="If Feeds/Communication is checked, SalesFroce All Related Model Feeds details will be imported to the OpenERP Communication History."),
'contract': fields.boolean('Contarcts/Analytic Account', help="If Contarcts/Analytic Account is checked, SalesFroce Contarcts details will be imported to the OpenERP Analytic Account."),
'note': fields.boolean('Notes', help="If Notes is checked, SalesFroce Notes details will be imported to the OpenERP Email History."),
'email': fields.char('Email address to notify', size=128, help="On Successful import the Email is Send to the mention email address."),
@@ -1056,9 +1122,11 @@
if current.attachment:
nodes.append('Attachment')
if current.document:
- nodes.extend(['Folder' ,'Document'])
+ nodes.extend(['Folder', 'Document'])
if current.product:
nodes.append('Product2')
+ if current.feed:
+ nodes.extend(["AccountFeed", "CaseFeed", "ContactFeed", "ContractFeed", "EventFeed", "LeadFeed", "OpportunityFeed", "Product2Feed", "TaskFeed", "UserFeed"])
if current.contract:
nodes.append('Contract')
if current.note:
=== modified file 'import_salesforce/wizard/import_salesforce_view.xml'
--- import_salesforce/wizard/import_salesforce_view.xml 2011-07-25 06:11:17 +0000
+++ import_salesforce/wizard/import_salesforce_view.xml 2011-07-25 09:12:43 +0000
@@ -10,7 +10,7 @@
<form string="Import Data From Saleforce">
<group col="8">
<group colspan="2" width="200" col="1" >
- <label colspan="1" string="The Module bridges the Salesforce and OpenERP. Using the module SaleForce 'Leads', 'Opportunity','Contacts','Account','Cases','User','Events', 'Activity', 'Task', 'Attachment', 'Folder' , 'Employees', 'Documents', 'Product' and Other history Detail documents can be imported to OpenERP on single click."/>
+ <label colspan="1" string="The Module bridges the Salesforce and OpenERP. Using the module SaleForce 'Leads', 'Opportunity','Contacts','Account','Cases','User','Events', 'Activity', 'Task', 'Attachment', 'Folder' , 'Employees', 'Documents', 'Product' and Other history Detail documents can be imported to OpenERP on single click."/>
</group>
<separator string="" orientation="vertical" colspan="1" rowspan="21"/>
<group colspan="4">
@@ -43,6 +43,7 @@
<field name='task'/>
<field name='product'/>
<field name='employee'/>
+ <field name='feed'/>
<field name='note'/>
</group>
</group>
@@ -50,11 +51,11 @@
<separator string="Email Notification When Import Finished" colspan="2"/>
<field name="email" colspan="2"/>
</group>
- <group colspan="4" col="2" groups="base.group_no_one">
+ <group colspan="4" col="2" 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">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
_______________________________________________
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