Harry (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-contact-linkedin into
lp:~openerp-dev/openobject-addons/trunk-addons-linkedin-jra.
Requested reviews:
OpenERP R&D Team (openerp-dev)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-contact-linkedin/+merge/107181
Changes:
===========
-> clean LinkedinConnector in js
-> clean template of search box
-> fields mapping stuff are moved into onchange event on sever side.
Thanks
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-contact-linkedin/+merge/107181
Your team OpenERP R&D Team is requested to review the proposed merge of
lp:~openerp-dev/openobject-addons/trunk-contact-linkedin into
lp:~openerp-dev/openobject-addons/trunk-addons-linkedin-jra.
=== modified file 'web_linkedin/__openerp__.py'
--- web_linkedin/__openerp__.py 2012-04-24 11:52:23 +0000
+++ web_linkedin/__openerp__.py 2012-05-24 10:04:47 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
{
"name" : "LinkedIn Integration",
'version': '0.1',
@@ -26,3 +27,33 @@
'application': True,
'auto_install': False,
}
+=======
+{
+ "name" : "LinkedIn Integration",
+ 'version': '0.1',
+ 'category': 'Tools',
+ 'complexity': "easy",
+ "description":
+ """
+ OpenERP Web LinkedIn module.
+ This module provides the Integration of the LinkedIn with OpenERP.
+ """,
+ 'update_xml': [
+ 'res_partner_view.xml',
+ 'web_linkedin_installer_view.xml',
+ ],
+ "depends" : ["base"],
+ "js": [
+ "static/src/js/linkedin.js"
+ ],
+ "css": [
+ "static/src/css/linkedin.css"
+ ],
+ 'qweb': [
+ "static/src/xml/linkedin.xml"
+ ],
+ 'installable': True,
+ 'application': True,
+ 'auto_install': False,
+}
+>>>>>>> MERGE-SOURCE
=== modified file 'web_linkedin/res_partner_view.xml'
--- web_linkedin/res_partner_view.xml 2012-05-11 13:30:51 +0000
+++ web_linkedin/res_partner_view.xml 2012-05-24 10:04:47 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
<?xml version="1.0"?>
<openerp>
<data>
@@ -19,3 +20,34 @@
</record>
</data>
</openerp>
+=======
+<?xml version="1.0"?>
+<openerp>
+ <data>
+ <record id="view_linkedin_partner_form" model="ir.ui.view">
+ <field name="name">res.partner.linkedin.inherit</field>
+ <field name="model">res.partner</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="base.view_partner_form"/>
+ <field name="arch" type="xml">
+ <field name="name" position="replace">
+ <field name="name" nolabel="1" widget="linkedin" on_change="onchange_linkedin(name)"/>
+ </field>
+ </field>
+ </record>
+
+ <record id="view_linkedin_company_form" model="ir.ui.view">
+ <field name="name">res.company.linkedin.inherit</field>
+ <field name="model">res.company</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="base.view_company_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//page[@string='Configuration']" position="inside">
+ <separator string="Linkedin" colspan="4"/>
+ <field name="linkedin_api_key"/>
+ </xpath>
+ </field>
+ </record>
+ </data>
+</openerp>
+>>>>>>> MERGE-SOURCE
=== modified file 'web_linkedin/static/src/css/linkedin.css'
--- web_linkedin/static/src/css/linkedin.css 2012-05-08 13:30:59 +0000
+++ web_linkedin/static/src/css/linkedin.css 2012-05-24 10:04:47 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
.ul-ldn-dropdown {
list-style: none outside none;
padding: 1px;
@@ -116,3 +117,66 @@
display: block;
position:relative;
}
+=======
+.oe_linkedin_button_loading {
+ width: 20px;
+ height: 20px;
+}
+.oe_linkedin_button {
+ background: url("http://static02.linkedin.com/scds/common/u/img/sprite/sprite_connect_v13.png") no-repeat scroll 0 -276px transparent !important;
+ width: 20px;
+ height: 20px;
+ cursor: pointer;
+}
+.oe_linkedin_search_box {
+ background: none repeat scroll 0 0%, -moz-linear-gradient(#EFEFEF, #D8D8D8) repeat scroll 0 0 transparent;
+ background: none repeat scroll 0 0%, -webkit-linear-gradient(#EFEFEF, #D8D8D8) repeat scroll 0 0 transparent;
+ border: 1px solid #ABABAB;
+ border-radius: 3px 3px 3px 3px;
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(255, 255, 255, 0.8) inset;
+ max-height: 450px;
+ -webkit-box-shadow: 0 3px 10px #888;
+ position: absolute;
+ z-index: 1;
+}
+.oe_linkedin_title .oe_linkedin_message{
+ color:gray;
+ text-align: right !important;
+ width:90px;
+ padding:3px !important;
+}
+.oe_linkedin_search_items {
+ list-style: none outside none;
+ padding: 1px;
+ max-height: 500px;
+ margin: 0px;
+ background-color: rgb(255, 255, 255);
+ border: 1px solid rgb(153, 153, 153);
+ width:280px;
+}
+.oe_linkedin_search_item {
+ margin: 0px;
+ display: block;
+ cursor: default;
+ padding: 3px;
+ border: 1px solid rgb(255, 255, 255);
+ background-color: transparent;
+}
+.oe_linkedin_search_item td{
+ font-size:10px;
+ font-weight:normal;
+}
+.oe_linkedin_search_item td img{
+ width:30px;
+ align:baseline;
+ padding:3px;
+}
+
+.oe_linkedin_search_item:hover {
+ margin: 0px;
+ display: block;
+ cursor: default;
+ border: 1px solid rgb(10, 36, 106);
+ background-color: rgb(182, 189, 210)
+}
+>>>>>>> MERGE-SOURCE
=== added file 'web_linkedin/static/src/img/loading.gif'
Binary files web_linkedin/static/src/img/loading.gif 1970-01-01 00:00:00 +0000 and web_linkedin/static/src/img/loading.gif 2012-05-24 10:04:47 +0000 differ
=== modified file 'web_linkedin/static/src/js/linkedin.js'
--- web_linkedin/static/src/js/linkedin.js 2012-05-22 10:03:55 +0000
+++ web_linkedin/static/src/js/linkedin.js 2012-05-24 10:04:47 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
/*---------------------------------------------------------
* OpenERP web_linkedin (module)
*---------------------------------------------------------*/
@@ -524,3 +525,250 @@
});
};
// vim:et fdc=0 fdl=0:
+=======
+openerp.web_linkedin = function(instance) {
+ var QWeb = instance.web.qweb;
+ instance.web_linkedin.LinkedinConnector = instance.web.Class.extend({
+ private_keyword: 'private',
+ contact_fields: ["id", "first-name", "last-name", "picture-url", "public-profile-url", "formatted-name", "location", "phone-numbers", "im-accounts","main-address", "headline"],
+ company_fields: ["id", "name", "description", "industry", "logo-url", "website-url", "locations", "twitter-id"],
+ get_api_key: function(){
+ var self = this;
+ var user = new instance.web.DataSet(self, 'res.users');
+ return user.read_ids(this.session.uid, ['linkedin_api_key']).done(function(result){
+ if (result['linkedin_api_key'] != false){
+ self.api_key = result['linkedin_api_key'];
+ }
+ });
+ },
+ init: function(session, resultCallback){
+ var self = this;
+ this.session = session;
+ this.api_url = "http://platform.linkedin.com/in.js?async=true";
+ this.get_api_key().pipe(function(){
+ $(document).ready(function() {
+ $.getScript(self.api_url, function success() {
+ IN.init({
+ onload: resultCallback,
+ api_key: self.api_key,
+ authorize: true
+ });
+
+ });
+ });
+ });
+
+ },
+ check_authorize: function(){
+ this.isAuthorized = IN.User.isAuthorized();
+ },
+ do_authorize: function(){
+ this.isAuthorized = IN.User.isAuthorized();
+ var self = this;
+ if (this.isAuthorized == false){
+ IN.User.authorize(function(result){
+ self.isAuthorized = IN.User.isAuthorized();
+ });
+ }
+ },
+ raw: function(url, search, fields, params, resultCallback){
+ args = false;
+ if (fields && fields.length != 0){
+ args = ":("+search+":(";
+ for (i=0;i<fields.length-1;i++){
+ args = args + fields[i] + ',';
+ }
+ args = args + fields[i] + "))";
+ }
+ url = "/" + url;
+ if (args){
+ url = url + args;
+ }
+ IN.API.Raw(url).
+ params(params).
+ result(resultCallback);
+ },
+ search_employee: function(company_name, resultCallback){
+ params = {"keywords": company_name};
+ this.search_contact(params, true, resultCallback);
+ },
+ search_contact: function(params, relation, resultCallback){
+ var self = this;
+ if(relation){
+ new_fields = _.clone(this.contact_fields);
+ new_fields.push("relation-to-viewer:(related-connections)");
+ }
+ else{
+ new_fields = this.contact_fields;
+ }
+ this.raw("people-search", "people", this.contact_fields, params, function(result){
+ values = [];
+ if (result && result.people){
+ values = _.filter(result.people.values, function(item){
+ if((item.firstName && item.firstName.toLowerCase() != self.private_keyword) || (item.lastName && item.lastName.toLowerCase() != self.private_keyword)){
+ item.isCompany = false;
+ return item;
+ }
+ });
+
+ }
+ resultCallback(values);
+ });
+ },
+ search_company: function(params, resultCallback){
+ var self = this;
+ this.raw("company-search", "companies", this.company_fields, params, function(result){
+ values = [];
+ if (result && result.companies){
+ values = _.filter(result.companies.values, function(item){
+ if(item.name && item.name.toLowerCase() != self.private_keyword){
+ item.isCompany = true;
+ return item;
+ }
+ });
+ }
+ resultCallback(values);
+ });
+ }
+ });
+ instance.web_linkedin.LinkedinSearchBox = instance.web.Widget.extend({
+ template: 'LinkedinSearchBox',
+ init: function(parent, data){
+ this.parent = parent;
+ this.data = data;
+ this.linkedin_connector = parent.linkedin_connector
+ },
+ renderElement: function(){
+ var self = this;
+ this.$element = $(QWeb.render(this.template, this.data));
+ this.$element.on('click','.oe_linkedin_search_item',function(event){
+ linkedin_id = $(event.currentTarget).attr('data-id');
+ $(".oe_linkedin_button_loading").attr("style", "visibility: none;");
+ self.onclick_search_item(linkedin_id);
+ });
+ },
+ destroy: function(){
+ this.parent.$element.find('.oe_linkedin_contents').empty();
+ },
+ search_item: function(linkedin_id){
+ item = false;
+ var item = _.filter(this.data.companies,function(item){
+ if(item.id==linkedin_id) return item;
+ });
+ if(_.isEmpty(item))
+ item = _.filter(this.data.people,function(item){
+ if(item.id==linkedin_id) return item;
+ });
+ if(!_.isEmpty(item))
+ return item[0];
+ return false;
+ },
+ set_value: function(value){
+ this.parent.set_value(value);
+ this.parent.view.do_onchange(this.parent);
+ this.destroy();
+ $(".oe_linkedin_button_loading").attr("style", "visibility: hidden;");
+ },
+ onclick_search_item: function(linkedin_id){
+ try{
+ var self = this;
+ var item = self.search_item(linkedin_id);
+ if (!item) return;
+ if(item.isCompany){
+ self.linkedin_connector.search_employee(item.name, function(result){
+ item.employee = result;
+ self.set_value(item);
+ });
+ }
+ else
+ self.set_value(item);
+ }
+ catch(err){
+ console.log(err);
+ //$(".oe_linkedin_button_loading").attr("style", "visibility: hidden;");
+ }
+
+ }
+ });
+ instance.web_linkedin.Linkedin = instance.web.form.FieldChar.extend({
+ template: 'Linkedin',
+ init: function (field_manager, node) {
+ this._super(field_manager, node);
+ this.data = {};
+ this.search_box = false;
+ try{
+ if (!this.session.linkedin_connector){
+ this.session.linkedin_connector = new instance.web_linkedin.LinkedinConnector(this.session);
+ }
+ this.linkedin_connector = this.session.linkedin_connector;
+ }
+ catch(err){
+ console.log(err);
+ }
+ },
+ render_value: function(){
+ this._super();
+ var self = this;
+ if (!this.get("effective_readonly")) {
+ this.$input = this.$element.find('input');
+ $(".oe_linkedin_button_loading").attr("style", "visibility: hidden;");
+ this.$element.find(".oe_linkedin_button").click(function(){
+
+ self.on_button_search();
+ });
+ }
+ },
+
+ on_button_search: function() {
+ var self = this;
+ var searchValue = self.$input.attr("value");
+
+
+ try{
+ this.data.people = [];
+ this.data.companies = [];
+ if(self.search_box){
+ self.search_box.destroy();
+ }
+ //todo: use pipe, $when, then
+ self.linkedin_connector.check_authorize();
+ if(!self.linkedin_connector.isAuthorized){
+ self.linkedin_connector.do_authorize();
+ return;
+ }
+ $(".oe_linkedin_button_loading").attr("style", "visibility: none;");
+ self.linkedin_connector.search_company({'keywords': searchValue, 'count': 4}, function(result){
+ self.data.companies = result;
+ self.do_open_search_box();
+ });
+ self.linkedin_connector.search_contact({'keywords': searchValue, 'count': 4}, false, function(result){
+ self.data.people = result;
+ self.do_open_search_box();
+ });
+ }
+ catch(err){
+ console.log(err);
+ //$(".oe_linkedin_button_loading").attr("style", "visibility: hidden;");
+ }
+ },
+ do_open_search_box: function(){
+ var self = this;
+ if (!self.search_box){
+ self.search_box = new instance.web_linkedin.LinkedinSearchBox(self, self.data);
+ }
+
+ $.when(this.data.companies && this.data.people).then(function(){
+ $(".oe_linkedin_button_loading").attr("style", "visibility: hidden;");
+ self.$element.find(".oe_linkedin_message").empty();
+ if (self.data.companies.length == 0 && self.data.people.length == 0){
+ self.$element.find(".oe_linkedin_message").append("Contact is not found in linkedin...");
+ }
+ });
+ self.search_box.appendTo(this.$element.find(".oe_linkedin_contents"));
+ },
+ }),
+ instance.web.form.widgets.add(
+ 'linkedin', 'instance.web_linkedin.Linkedin');
+};
+// vim:et fdc=0 fdl=0:
+>>>>>>> MERGE-SOURCE
=== modified file 'web_linkedin/static/src/xml/linkedin.xml'
--- web_linkedin/static/src/xml/linkedin.xml 2012-05-22 10:03:55 +0000
+++ web_linkedin/static/src/xml/linkedin.xml 2012-05-24 10:04:47 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1:
-->
@@ -132,4 +133,92 @@
</tr>
</t>
</t>
-</templates>
\ No newline at end of file
+</templates>=======
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+<t t-name="Linkedin" t-extend="FieldChar">
+<!-- Will replace via extending FieldChar -->
+
+ <t t-jquery="input" t-operation="after">
+ <t t-if="!widget.get('effective_readonly')">
+ <img class="oe_linkedin_button" border="0"/>
+ <img class="oe_linkedin_button_loading" border="0" t-att-src='_s + "/web_linkedin/static/src/img/loading.gif"'/>
+ <span class="oe_linkedin_message"></span>
+ <div class="oe_linkedin_contents">
+ </div>
+ </t>
+ </t>
+
+</t>
+<t t-name="LinkedinSearchBox">
+ <div class="oe_linkedin_search_box">
+ <table>
+ <t t-if="people.length">
+ <tr>
+ <td class="oe_linkedin_title"><span>People</span></td>
+ <td>
+ <t t-call="LinkedinSearchItems"><t t-set="items" t-value="people"/></t>
+ </td>
+ </tr>
+ </t>
+ <t t-if="companies.length">
+ <tr>
+ <td class="oe_linkedin_title"><span>Companies</span></td>
+ <td><t t-call="LinkedinSearchItems"><t t-set="items" t-value="companies"/></t></td>
+ </tr>
+ </t>
+ </table>
+ </div>
+</t>
+<t t-name="LinkedinSearchItems">
+ <ul class="oe_linkedin_search_items">
+ <t t-foreach="items.length" t-as="index">
+ <t t-call="LinkedinSearchItem">
+ <t t-set="item" t-value="items[index]"/>
+ </t>
+ </t>
+ </ul>
+</t>
+<t t-name="LinkedinSearchItem">
+ <li class="oe_linkedin_search_item" t-att-data-id="item.id">
+ <table>
+ <tr>
+ <t t-if="item.isCompany">
+ <td>
+ <t t-if="item.hasOwnProperty('logoUrl')">
+ <img t-att-src="item.logoUrl"/>
+ </t>
+ <t t-if="!item.hasOwnProperty('logoUrl')">
+ <img src='http://static02.linkedin.com/scds/common/u/img/icon/icon_no_photo_80x80.png' />
+ </t>
+ </td>
+ <td>
+ <t t-esc="item.name"/>
+ <t t-esc="item.industry" />
+ </td>
+ </t>
+ <t t-if="!item.isCompany">
+ <td>
+ <t t-if="item.hasOwnProperty('pictureUrl')">
+ <img t-att-src="item.pictureUrl"/>
+ </t>
+ <t t-if="!item.hasOwnProperty('pictureUrl')">
+ <img src='http://static02.linkedin.com/scds/common/u/img/icon/icon_no_photo_80x80.png' />
+ </t>
+ </td>
+ <td>
+ <t t-if="item.formattedName">
+ <t t-esc="item.formattedName"/>
+ </t>
+ <t t-if="!item.formattedName">
+ <t t-esc="item.firstName + ' ' + item.lastName" />
+ </t>
+ <t t-esc="item.headline" />
+ </td>
+ </t>
+ </tr>
+ </table>
+ </li>
+</t>
+</templates>
+>>>>>>> MERGE-SOURCE
=== modified file 'web_linkedin/web_linkedin.py'
--- web_linkedin/web_linkedin.py 2012-05-07 08:43:05 +0000
+++ web_linkedin/web_linkedin.py 2012-05-24 10:04:47 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
# -*- coding: utf-8 -*-
##############################################################################
#
@@ -74,3 +75,191 @@
return base64.b64encode(bfile.read())
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+=======
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import base64
+import urllib
+import xmlrpclib
+import zlib
+
+
+from osv import fields, osv
+class company(osv.osv):
+ _inherit = 'res.company'
+ _columns = {
+ 'linkedin_api_key': fields.char('LinkedIn API key', size=128),
+ }
+ _defaults = {
+ 'linkedin_api_key': 'ejm0ci626808'
+ }
+
+class user(osv.osv):
+ _inherit = 'res.users'
+ _columns = {
+ 'linkedin_api_key': fields.related('company_id', 'linkedin_api_key',type="char",string='LinkedIn API key', size=128),
+ }
+
+class res_partner(osv.osv):
+ _inherit = 'res.partner'
+
+ _columns = {
+ 'linkedin_id': fields.text('Linkedin Id', readonly=True),
+ }
+ def onchange_linkedin(self, cr, uid, ids, linkedin_data):
+ contact_values = {}
+ warning = {}
+ contact_keys = list(set(self.map_fields.values()))
+ for key in contact_keys:
+ if key == 'name' or key == 'photo':
+ continue
+ contact_values.update({key:False})
+ for contact in self.browse(cr, uid, ids):
+ if contact.linkedin_id:
+ warning = 'already imported from linkedin'
+ if(type(linkedin_data) == dict):
+ contact_values = self.convert(cr, uid, linkedin_data)
+ return {'value': contact_values, 'warning': warning}
+
+ map_fields = {
+ #linkedin_field, value: openerp_field
+ 'name': 'name',
+ 'formattedName': 'name',
+ 'firstName': 'name',
+ 'id': 'linkedin_id',
+ #'twitterId': 'twitter_id',
+ #'twitterAccounts': 'twitter_id',
+ #'publicProfileUrl': 'profile_id',
+ 'phoneNumbers': 'phone',
+ 'phone1': 'phone',
+ 'phone2': 'mobile',
+ #'imAccounts': 'email',
+ 'pictureUrl': 'photo',
+ 'logoUrl': 'photo',
+ 'mainAddress': 'street',
+ 'street1': 'street',
+ 'street2' : 'street2',
+ 'city': 'city',
+ 'postalCode': 'zip',
+ 'code': 'country_id',
+ 'websiteUrl': 'website',
+ 'fax': 'fax',
+ 'isHeadquarters': 'use_parent_address',
+ 'isActive': 'active',
+ 'state': 'state_id',
+ 'isCompany': 'is_company',
+ 'employee': 'child_ids',
+ }
+
+ def _convert_data(self, cr, uid, data):
+ value = {}
+ for field_name, field_value in data.items():
+ if field_name == 'state':
+ state_id = self.pool.get('res.country.state').search(cr, uid, [('name','=',field_value) or ('code','=',field_value.upper())])
+ if country_id:
+ value['state_id'] = state_id[0]
+ continue
+
+ openerp_field_name = self.map_fields.get(field_name)
+ value[openerp_field_name] = field_value
+
+ return value
+
+ def _convert_location(self, cr, uid, location):
+ value = {}
+ address = location.get("address") and location.pop("address") or {}
+ country = location.get("country") and location.pop("country") or {}
+ contact_info = location.get("contactInfo") and location.pop("contactInfo") or {}
+ value.update(self._convert_data(cr, uid, contact_info))
+ value.update(self._convert_data(cr, uid, address))
+
+ country_code = country.get('code') or location.get('countryCode')
+ if country_code:
+ country_id = self.pool.get('res.country').search(cr, uid, [('code','=',country_code.upper())])
+ if country_id:
+ value['country_id'] = country_id[0]
+
+ value.update(self._convert_data(cr, uid, location))
+ # for multiple location set required field name
+ #value['name']= 'address'
+
+ return value
+
+ def convert(self, cr, uid, linkedin_data):
+ '''
+ json_object contains contact details of linkedin profile in json format
+ '''
+ value = {}
+ # set warning message if already imported details from linkedin after checking linkedin_id
+ for linkedin_field_name, linkedin_field_value in linkedin_data.items():
+
+ if linkedin_field_name == 'formattedName' and linkedin_data.get('location').get('name'):
+ linkedin_data.get('location').pop('name')
+
+ if linkedin_field_name == 'location':
+ value.update(self._convert_location(cr, uid, linkedin_data.get('location')))
+ continue
+
+ if linkedin_field_name == 'locations':
+ for location in linkedin_field_value.get('values',{}):
+ value.update(self._convert_location(cr, uid, location))
+ #for multiple locations
+ #if contact_values:
+ # value["child_ids"] = contact_values
+ continue
+
+ if linkedin_field_name == 'employee':
+ emp_values = []
+ for employee in linkedin_field_value:
+ #if partener already exist
+ #linkedin_id = employee.get('id')
+ #partner_id = self.pool.get('res.partner').search(cr, uid, [('linkedin_id','=',linkedin_id)])
+ #if partner_id:
+ # emp_values.append(partner_id[0])
+ # continue
+ if employee.get('location') and employee.get('location').get('name'):
+ employee.get('location').pop('name')
+ emp_values.append(self.convert(cr, uid, employee))
+ if emp_values:
+ value["child_ids"] = emp_values
+ continue
+
+ if linkedin_field_name not in self.map_fields:
+ continue
+
+ openerp_field_name = self.map_fields.get(linkedin_field_name)
+ #if first name found, name = first name + last name
+ if linkedin_field_name == 'firstName':
+ linkedin_field_value = linkedin_data.get("firstName")+' '+ linkedin_data.get("lastName")
+
+ #if linkedin_field_name == 'twitterAccounts':
+ # linkedin_field_value = linkedin_field_value[0].get("providerAccountName")
+
+ if linkedin_field_name == 'phoneNumbers':
+ linkedin_field_value = linkedin_field_value.get("values",{}) and linkedin_field_value.get("values")[0].get("phoneNumbers") or []
+
+ if openerp_field_name == 'photo': # photo url
+ linkedin_field_value = base64.encodestring(urllib.urlopen(linkedin_field_value).read())
+
+ value[openerp_field_name] = linkedin_field_value
+ return value
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+>>>>>>> MERGE-SOURCE
_______________________________________________
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