summaryrefslogtreecommitdiff
path: root/addons/web_linkedin/static/src/js/linkedin.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2013-02-05 10:22:15 +0100
committerChristophe Matthieu <chm@openerp.com>2013-02-05 10:22:15 +0100
commit27625e4f8835e2568d9709322f4dc1df1bebf09f (patch)
treeb04992bbf4968c1be4e0918ed49bb2e94f5c9a9a /addons/web_linkedin/static/src/js/linkedin.js
parentba7adff518a9c9fdbc30e166c0eb75b06736e4ee (diff)
[FIX] linkedin: parent_id and job position
bzr revid: chm@openerp.com-20130205092215-0uy1rr2mmlj3qsby
Diffstat (limited to 'addons/web_linkedin/static/src/js/linkedin.js')
-rw-r--r--addons/web_linkedin/static/src/js/linkedin.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/addons/web_linkedin/static/src/js/linkedin.js b/addons/web_linkedin/static/src/js/linkedin.js
index 3f769bdafd1..423b7d5aade 100644
--- a/addons/web_linkedin/static/src/js/linkedin.js
+++ b/addons/web_linkedin/static/src/js/linkedin.js
@@ -226,6 +226,7 @@ openerp.web_linkedin = function(instance) {
var defs = [];
_.each(result, function (el) {
el.__type = "people";
+ el.__company = entity.universalName;
el.parent_id = self.field_manager.datarecord.id || false;
defs.push(self.create_or_modify_partner(el, true).then(function (data) {
// [0,0,data] if it's a new partner
@@ -263,17 +264,23 @@ openerp.web_linkedin = function(instance) {
}
});
var positions = (entity.positions || {}).values || [];
- if (positions.length && positions[0].isCurrent) {
- to_change.function = positions[0].title;
- if (!entity.parent_id) {
- var company_name = positions[0].company ? positions[0].company.name : false;
- if (company_name) {
+ for (key in positions) {
+ var position = positions[key];
+ if (position.isCurrent) {
+ var company_name = position.company ? position.company.name : false;
+ if (!entity.parent_id && company_name) {
defs.push(new instance.web.DataSetSearch(this, 'res.partner').call("search", [[["name", "=", company_name]]]).then(function (data) {
if(data[0]) to_change.parent_id = data[0];
+ else position.title = position.title + ' (' + company_name + ') ';
+ to_change.function = position.title;
}));
+ } else if (!entity.__company || !company_name || company_name == entity.__company) {
+ to_change.function = position.title + (company_name ? ' (' + company_name + ') ':'');
}
+ break;
}
- }
+ };
+
if (entity.parent_id) {
to_change.parent_id = entity.parent_id;
}
@@ -304,7 +311,7 @@ openerp.web_linkedin = function(instance) {
} else {
_.each(partners[0], function (val, key) {
if (val) {
- to_change[key] = val;
+ to_change[key] = typeof val == "object" && key.match(/_id$/) ? val[0] : val;
}
});
}