[IMP] jQuery deferred API changes refactoring. Changed 'then's in 'done'/'fail' and 'pipe's in 'then'

bzr revid: fme@openerp.com-20121031103148-r1slfpl2kcnajjd3
This commit is contained in:
Fabien Meghazi 2012-10-31 11:31:48 +01:00
parent 848cb19302
commit a2715888c1
23 changed files with 111 additions and 112 deletions

View File

@ -48,7 +48,7 @@ openerp.account = function (instance) {
this.last_group_by = group_by; this.last_group_by = group_by;
this.old_search = _.bind(this._super, this); this.old_search = _.bind(this._super, this);
var mod = new instance.web.Model("account.move.line", context, domain); var mod = new instance.web.Model("account.move.line", context, domain);
return mod.call("list_partners_to_reconcile", []).pipe(function(result) { return mod.call("list_partners_to_reconcile", []).then(function(result) {
var current = self.current_partner !== null ? self.partners[self.current_partner][0] : null; var current = self.current_partner !== null ? self.partners[self.current_partner][0] : null;
self.partners = result; self.partners = result;
var index = _.find(_.range(self.partners.length), function(el) { var index = _.find(_.range(self.partners.length), function(el) {
@ -74,7 +74,7 @@ openerp.account = function (instance) {
return fct(); return fct();
} else { } else {
return new instance.web.Model("res.partner").call("read", return new instance.web.Model("res.partner").call("read",
[self.partners[self.current_partner][0], ["last_reconciliation_date"]]).pipe(function(res) { [self.partners[self.current_partner][0], ["last_reconciliation_date"]]).then(function(res) {
self.last_reconciliation_date = self.last_reconciliation_date =
instance.web.format_value(res.last_reconciliation_date, {"type": "datetime"}, _t("Never")); instance.web.format_value(res.last_reconciliation_date, {"type": "datetime"}, _t("Never"));
return fct(); return fct();
@ -92,7 +92,7 @@ openerp.account = function (instance) {
return false; return false;
} }
new instance.web.Model("ir.model.data").call("get_object_reference", ["account", "action_view_account_move_line_reconcile"]).pipe(function(result) { new instance.web.Model("ir.model.data").call("get_object_reference", ["account", "action_view_account_move_line_reconcile"]).then(function(result) {
var additional_context = _.extend({ var additional_context = _.extend({
active_id: ids[0], active_id: ids[0],
active_ids: ids, active_ids: ids,
@ -101,7 +101,7 @@ openerp.account = function (instance) {
return self.rpc("/web/action/load", { return self.rpc("/web/action/load", {
action_id: result[1], action_id: result[1],
context: additional_context context: additional_context
}).then(function (result) { }).done(function (result) {
result.context = _.extend(result.context || {}, additional_context); result.context = _.extend(result.context || {}, additional_context);
result.flags = result.flags || {}; result.flags = result.flags || {};
result.flags.new_window = true; result.flags.new_window = true;
@ -116,7 +116,7 @@ openerp.account = function (instance) {
mark_as_reconciled: function() { mark_as_reconciled: function() {
var self = this; var self = this;
var id = self.partners[self.current_partner][0]; var id = self.partners[self.current_partner][0];
new instance.web.Model("res.partner").call("mark_as_reconciled", [[id]]).pipe(function() { new instance.web.Model("res.partner").call("mark_as_reconciled", [[id]]).then(function() {
self.do_search(self.last_domain, self.last_context, self.last_group_by); self.do_search(self.last_domain, self.last_context, self.last_group_by);
}); });
}, },

View File

@ -3,7 +3,7 @@ openerp.auth_anonymous = function(instance) {
instance.web.Login.include({ instance.web.Login.include({
start: function() { start: function() {
var self = this; var self = this;
return $.when(this._super()).pipe(function() { return $.when(this._super()).then(function() {
var dblist = self._db_list || []; var dblist = self._db_list || [];
if (!self.session.session_is_valid() && dblist.length === 1) { if (!self.session.session_is_valid() && dblist.length === 1) {
self.remember_credentials = false; self.remember_credentials = false;

View File

@ -12,7 +12,7 @@ openerp.auth_oauth = function(instance) {
} else if(this.params.oauth_error === 2) { } else if(this.params.oauth_error === 2) {
this.do_warn("Authentication error",""); this.do_warn("Authentication error","");
} }
return d.then(this.do_oauth_load).fail(function() { return d.done(this.do_oauth_load).fail(function() {
self.do_oauth_load([]); self.do_oauth_load([]);
}); });
}, },
@ -23,7 +23,7 @@ openerp.auth_oauth = function(instance) {
do_oauth_load: function() { do_oauth_load: function() {
var db = this.$("form [name=db]").val(); var db = this.$("form [name=db]").val();
if (db) { if (db) {
this.rpc("/auth_oauth/list_providers", { dbname: db }).then(this.on_oauth_loaded); this.rpc("/auth_oauth/list_providers", { dbname: db }).done(this.on_oauth_loaded);
} }
}, },
on_oauth_loaded: function(result) { on_oauth_loaded: function(result) {

View File

@ -69,7 +69,7 @@ instance.web.Login = instance.web.Login.extend({
_check_error: function() { _check_error: function() {
var self = this; var self = this;
if (this.params.loginerror !== undefined) { if (this.params.loginerror !== undefined) {
this.rpc('/auth_openid/login/status', {}).then(function(result) { this.rpc('/auth_openid/login/status', {}).done(function(result) {
if (_.contains(['success', 'failure'], result.status) && result.message) { if (_.contains(['success', 'failure'], result.status) && result.message) {
self.do_warn('Invalid OpenID Login', result.message); self.do_warn('Invalid OpenID Login', result.message);
} }
@ -106,7 +106,7 @@ instance.web.Login = instance.web.Login.extend({
do_openid_login: function(db, openid_url) { do_openid_login: function(db, openid_url) {
var self = this; var self = this;
this.rpc('/auth_openid/login/verify', {'db': db, 'url': openid_url}).then(function(result) { this.rpc('/auth_openid/login/verify', {'db': db, 'url': openid_url}).done(function(result) {
if (result.error) { if (result.error) {
self.do_warn(result.title, result.error); self.do_warn(result.title, result.error);
return; return;

View File

@ -139,7 +139,7 @@ openerp.base_import = function (instance) {
this._super(), this._super(),
this.Import.call('create', [{ this.Import.call('create', [{
'res_model': this.res_model 'res_model': this.res_model
}]).then(function (id) { }]).done(function (id) {
self.id = id; self.id = id;
self.$('input[name=import_id]').val(id); self.$('input[name=import_id]').val(id);
}) })
@ -198,7 +198,7 @@ openerp.base_import = function (instance) {
!this.$('input.oe_import_has_header').prop('checked')); !this.$('input.oe_import_has_header').prop('checked'));
this.Import.call( this.Import.call(
'parse_preview', [this.id, this.import_options()]) 'parse_preview', [this.id, this.import_options()])
.then(function (result) { .done(function (result) {
var signal = result.error ? 'preview_failed' : 'preview_succeeded'; var signal = result.error ? 'preview_failed' : 'preview_succeeded';
self[signal](result); self[signal](result);
}); });
@ -337,11 +337,11 @@ openerp.base_import = function (instance) {
}, },
onvalidate: function () { onvalidate: function () {
return this.call_import({ dryrun: true }) return this.call_import({ dryrun: true })
.then(this.proxy('validated')); .done(this.proxy('validated'));
}, },
onimport: function () { onimport: function () {
var self = this; var self = this;
return this.call_import({ dryrun: false }).then(function (message) { return this.call_import({ dryrun: false }).done(function (message) {
if (!_.any(message, function (message) { if (!_.any(message, function (message) {
return message.type === 'error' })) { return message.type === 'error' })) {
self['import_succeeded'](); self['import_succeeded']();

View File

@ -46,7 +46,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
delete(action.attrs.colspan); delete(action.attrs.colspan);
var action_id = _.str.toNumber(action.attrs.name); var action_id = _.str.toNumber(action.attrs.name);
if (!_.isNaN(action_id)) { if (!_.isNaN(action_id)) {
self.rpc('/web/action/load', {action_id: action_id}).then(function(result) { self.rpc('/web/action/load', {action_id: action_id}).done(function(result) {
self.on_load_action(result, column_index + '_' + action_index, action.attrs); self.on_load_action(result, column_index + '_' + action_index, action.attrs);
}); });
} }
@ -81,7 +81,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
this.rpc('/web/view/undo_custom', { this.rpc('/web/view/undo_custom', {
view_id: this.view.fields_view.view_id, view_id: this.view.fields_view.view_id,
reset: true reset: true
}).then(this.do_reload); }).done(this.do_reload);
}, },
on_change_layout: function() { on_change_layout: function() {
var self = this; var self = this;
@ -242,7 +242,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
}; };
var list = am.inner_widget.views.list; var list = am.inner_widget.views.list;
if (list) { if (list) {
list.deferred.then(function() { list.deferred.done(function() {
$(list.controller.groups).off('row_link').on('row_link', function(e, id) { $(list.controller.groups).off('row_link').on('row_link', function(e, id) {
new_form_action(id); new_form_action(id);
}); });
@ -250,7 +250,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
} }
var kanban = am.inner_widget.views.kanban; var kanban = am.inner_widget.views.kanban;
if (kanban) { if (kanban) {
kanban.deferred.then(function() { kanban.deferred.done(function() {
kanban.controller.open_record = function(id, editable) { kanban.controller.open_record = function(id, editable) {
new_form_action(id, editable); new_form_action(id, editable);
}; };
@ -335,7 +335,7 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
e.preventDefault(); e.preventDefault();
self.add_dashboard(); self.add_dashboard();
}); });
return this.load_data().then(this.proxy("render_data")); return this.load_data().done(this.proxy("render_data"));
}, },
load_data:function(){ load_data:function(){
var board = new instance.web.Model('board.board'); var board = new instance.web.Model('board.board');
@ -347,7 +347,7 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
return new instance.web.Model('ir.model.data') return new instance.web.Model('ir.model.data')
.query(['res_id']) .query(['res_id'])
.filter([['name','=','menu_reporting_dashboard']]) .filter([['name','=','menu_reporting_dashboard']])
.first().pipe(function (result) { .first().then(function (result) {
var menu = _(dashboard_menu).chain() var menu = _(dashboard_menu).chain()
.pluck('children') .pluck('children')
.flatten(true) .flatten(true)
@ -382,7 +382,7 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
domain: domain, domain: domain,
view_mode: view_parent.active_view, view_mode: view_parent.active_view,
name: this.$el.find("input").val() name: this.$el.find("input").val()
}).then(function(r) { }).done(function(r) {
if (r === false) { if (r === false) {
self.do_warn("Could not add filter to dashboard"); self.do_warn("Could not add filter to dashboard");
} else { } else {

View File

@ -15,7 +15,7 @@ openerp.edi.EdiView = openerp.web.Widget.extend({
this._super(); this._super();
var self = this; var self = this;
var param = {"db": self.db, "token": self.token}; var param = {"db": self.db, "token": self.token};
return self.rpc('/edi/get_edi_document', param).then(this.on_document_loaded, this.on_document_failed); return self.rpc('/edi/get_edi_document', param).done(this.on_document_loaded).fail(this.on_document_failed);
}, },
on_document_loaded: function(docs){ on_document_loaded: function(docs){
this.doc = docs[0]; this.doc = docs[0];
@ -108,7 +108,7 @@ openerp.edi.EdiView = openerp.web.Widget.extend({
}); });
openerp.edi.edi_view = function (db, token) { openerp.edi.edi_view = function (db, token) {
openerp.session.session_bind().then(function () { openerp.session.session_bind().done(function () {
new openerp.edi.EdiView(null,db,token).appendTo($("body").addClass('openerp')); new openerp.edi.EdiView(null,db,token).appendTo($("body").addClass('openerp'));
}); });
} }
@ -149,11 +149,11 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
}, },
do_import: function() { do_import: function() {
this.rpc('/edi/import_edi_url', {url: this.url}).then(this.on_imported, this.on_imported_error); this.rpc('/edi/import_edi_url', {url: this.url}).done(this.on_imported).fail(this.on_imported_error);
}, },
on_imported: function(response) { on_imported: function(response) {
if ('action' in response) { if ('action' in response) {
this.rpc("/web/session/save_session_action", {the_action: response.action}).then(function(key) { this.rpc("/web/session/save_session_action", {the_action: response.action}).done(function(key) {
window.location = "/#sa="+encodeURIComponent(key); window.location = "/#sa="+encodeURIComponent(key);
}); });
} }
@ -188,7 +188,7 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
}); });
openerp.edi.edi_import = function (url) { openerp.edi.edi_import = function (url) {
openerp.session.session_bind().then(function () { openerp.session.session_bind().done(function () {
new openerp.edi.EdiImport(null,url).appendTo($("body").addClass('openerp')); new openerp.edi.EdiImport(null,url).appendTo($("body").addClass('openerp'));
}); });
} }

View File

@ -20,9 +20,9 @@ var _t = instance.web._t;
on_google_doc: function() { on_google_doc: function() {
var self = this; var self = this;
var form = self.getParent(); var form = self.getParent();
form.sidebar_context().then(function (context) { form.sidebar_context().done(function (context) {
var ds = new instance.web.DataSet(this, 'ir.attachment', context); var ds = new instance.web.DataSet(this, 'ir.attachment', context);
ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context]).then(function(r) { ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context]).done(function(r) {
if (r == 'False') { if (r == 'False') {
var params = { var params = {
error: response, error: response,

View File

@ -57,7 +57,7 @@ openerp.hr_attendance = function (instance) {
var employee = new instance.web.DataSetSearch(self, 'hr.employee', self.session.user_context, [ var employee = new instance.web.DataSetSearch(self, 'hr.employee', self.session.user_context, [
['user_id', '=', self.session.uid] ['user_id', '=', self.session.uid]
]); ]);
return employee.read_slice(['id', 'name', 'state', 'last_sign', 'attendance_access']).pipe(function (res) { return employee.read_slice(['id', 'name', 'state', 'last_sign', 'attendance_access']).then(function (res) {
if (_.isEmpty(res) ) if (_.isEmpty(res) )
return; return;
if (res[0].attendance_access == false){ if (res[0].attendance_access == false){
@ -75,7 +75,7 @@ openerp.hr_attendance = function (instance) {
do_update: function () { do_update: function () {
this._super(); this._super();
var self = this; var self = this;
this.update_promise = this.update_promise.then(function () { this.update_promise = this.update_promise.done(function () {
if (self.attendanceslider) if (self.attendanceslider)
return; return;
self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self); self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self);

View File

@ -16,7 +16,7 @@ openerp.hr_recruitment = function(openerp) {
// Find their matching names // Find their matching names
var dataset = new openerp.web.DataSetSearch(self, 'hr.applicant_category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]); var dataset = new openerp.web.DataSetSearch(self, 'hr.applicant_category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]);
dataset.read_slice(['id', 'name']).then(function(result) { dataset.read_slice(['id', 'name']).done(function(result) {
_.each(result, function(v, k) { _.each(result, function(v, k) {
// Set the proper value in the DOM and display the element // Set the proper value in the DOM and display the element
self.$el.find('span[data-categ_id=' + v.id + ']').text(v.name); self.$el.find('span[data-categ_id=' + v.id + ']').text(v.name);

View File

@ -46,7 +46,7 @@ openerp.hr_timesheet_sheet = function(instance) {
var commands = this.field_manager.get_field_value("timesheet_ids"); var commands = this.field_manager.get_field_value("timesheet_ids");
this.res_o2m_drop.add(new instance.web.Model(this.view.model).call("resolve_2many_commands", ["timesheet_ids", commands, [], this.res_o2m_drop.add(new instance.web.Model(this.view.model).call("resolve_2many_commands", ["timesheet_ids", commands, [],
new instance.web.CompoundContext()])) new instance.web.CompoundContext()]))
.then(function(result) { .done(function(result) {
self.querying = true; self.querying = true;
self.set({sheets: result}); self.set({sheets: result});
self.querying = false; self.querying = false;
@ -57,7 +57,7 @@ openerp.hr_timesheet_sheet = function(instance) {
if (self.querying) if (self.querying)
return; return;
self.updating = true; self.updating = true;
self.field_manager.set_values({timesheet_ids: self.get("sheets")}).then(function() { self.field_manager.set_values({timesheet_ids: self.get("sheets")}).done(function() {
self.updating = false; self.updating = false;
}); });
}, },
@ -85,7 +85,7 @@ openerp.hr_timesheet_sheet = function(instance) {
var default_get; var default_get;
return this.render_drop.add(new instance.web.Model("hr.analytic.timesheet").call("default_get", [ return this.render_drop.add(new instance.web.Model("hr.analytic.timesheet").call("default_get", [
['account_id','general_account_id', 'journal_id','date','name','user_id','product_id','product_uom_id','to_invoice','amount','unit_amount'], ['account_id','general_account_id', 'journal_id','date','name','user_id','product_id','product_uom_id','to_invoice','amount','unit_amount'],
new instance.web.CompoundContext({'user_id': self.get('user_id')})]).pipe(function(result) { new instance.web.CompoundContext({'user_id': self.get('user_id')})]).then(function(result) {
default_get = result; default_get = result;
// calculating dates // calculating dates
dates = []; dates = [];
@ -108,7 +108,7 @@ openerp.hr_timesheet_sheet = function(instance) {
var account_ids = _.map(_.keys(accounts), function(el) { return el === "false" ? false : Number(el) }); var account_ids = _.map(_.keys(accounts), function(el) { return el === "false" ? false : Number(el) });
return new instance.web.Model("hr.analytic.timesheet").call("multi_on_change_account_id", [[], account_ids, return new instance.web.Model("hr.analytic.timesheet").call("multi_on_change_account_id", [[], account_ids,
new instance.web.CompoundContext({'user_id': self.get('user_id')})]).pipe(function(accounts_defaults) { new instance.web.CompoundContext({'user_id': self.get('user_id')})]).then(function(accounts_defaults) {
accounts = _(accounts).chain().map(function(lines, account_id) { accounts = _(accounts).chain().map(function(lines, account_id) {
account_defaults = _.extend({}, default_get, accounts_defaults[account_id]); account_defaults = _.extend({}, default_get, accounts_defaults[account_id]);
// group by days // group by days
@ -136,7 +136,7 @@ openerp.hr_timesheet_sheet = function(instance) {
// we need the name_get of the analytic accounts // we need the name_get of the analytic accounts
return new instance.web.Model("account.analytic.account").call("name_get", [_.pluck(accounts, "account"), return new instance.web.Model("account.analytic.account").call("name_get", [_.pluck(accounts, "account"),
new instance.web.CompoundContext()]).pipe(function(result) { new instance.web.CompoundContext()]).then(function(result) {
account_names = {}; account_names = {};
_.each(result, function(el) { _.each(result, function(el) {
account_names[el[0]] = el[1]; account_names[el[0]] = el[1];
@ -146,7 +146,7 @@ openerp.hr_timesheet_sheet = function(instance) {
}); });
});; });;
}); });
})).pipe(function(result) { })).then(function(result) {
// we put all the gathered data in self, then we render // we put all the gathered data in self, then we render
self.dates = dates; self.dates = dates;
self.accounts = accounts; self.accounts = accounts;
@ -222,7 +222,7 @@ openerp.hr_timesheet_sheet = function(instance) {
return; return;
} }
var ops = self.generate_o2m_value(); var ops = self.generate_o2m_value();
new instance.web.Model("hr.analytic.timesheet").call("on_change_account_id", [[], id]).pipe(function(res) { new instance.web.Model("hr.analytic.timesheet").call("on_change_account_id", [[], id]).then(function(res) {
var def = _.extend({}, self.default_get, res.value, { var def = _.extend({}, self.default_get, res.value, {
name: self.description_line, name: self.description_line,
unit_amount: 0, unit_amount: 0,

View File

@ -356,7 +356,7 @@ openerp.mail = function (session) {
this.context.default_parent_id, this.context.default_parent_id,
attachments, attachments,
this.parent_thread.context this.parent_thread.context
]).then(function (record) { ]).done(function (record) {
var thread = self.parent_thread; var thread = self.parent_thread;
// create object and attach to the thread object // create object and attach to the thread object
thread.message_fetch(false, false, [record], function (arg, data) { thread.message_fetch(false, false, [record], function (arg, data) {
@ -744,7 +744,7 @@ openerp.mail = function (session) {
} }
// if this message is read, all childs message display is read // if this message is read, all childs message display is read
this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).pipe(function () { this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).then(function () {
self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread'); self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread');
self.to_read = !self.to_read; self.to_read = !self.to_read;
}); });
@ -801,7 +801,7 @@ openerp.mail = function (session) {
on_vote: function (event) { on_vote: function (event) {
event.stopPropagation(); event.stopPropagation();
var self=this; var self=this;
return this.ds_message.call('vote_toggle', [[self.id]]).pipe(function (vote) { return this.ds_message.call('vote_toggle', [[self.id]]).then(function (vote) {
self.has_voted = vote; self.has_voted = vote;
self.vote_nb += self.has_voted ? 1 : -1; self.vote_nb += self.has_voted ? 1 : -1;
self.display_vote(); self.display_vote();
@ -826,7 +826,7 @@ openerp.mail = function (session) {
event.stopPropagation(); event.stopPropagation();
var self=this; var self=this;
var button = self.$('.oe_star:first'); var button = self.$('.oe_star:first');
return this.ds_message.call('favorite_toggle', [[self.id]]).pipe(function (star) { return this.ds_message.call('favorite_toggle', [[self.id]]).then(function (star) {
self.is_favorite=star; self.is_favorite=star;
if (self.is_favorite) { if (self.is_favorite) {
button.addClass('oe_starred'); button.addClass('oe_starred');
@ -1111,7 +1111,7 @@ openerp.mail = function (session) {
var thread_level = this.options.display_indented_thread > this.thread_level ? this.options.display_indented_thread - this.thread_level : 0; var thread_level = this.options.display_indented_thread > this.thread_level ? this.options.display_indented_thread - this.thread_level : 0;
return this.ds_message.call('message_read', [ids, fetch_domain, message_loaded_ids, thread_level, fetch_context, this.context.default_parent_id || undefined]) return this.ds_message.call('message_read', [ids, fetch_domain, message_loaded_ids, thread_level, fetch_context, this.context.default_parent_id || undefined])
.then(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message')); .done(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message'));
}, },
/** /**
@ -1578,7 +1578,7 @@ openerp.mail = function (session) {
load_searchview: function (defaults, hidden) { load_searchview: function (defaults, hidden) {
var self = this; var self = this;
this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false); this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false);
return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).then(function () { return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).done(function () {
self.searchview.on('search_data', self, self.do_searchview_search); self.searchview.on('search_data', self, self.do_searchview_search);
}); });
}, },
@ -1596,7 +1596,7 @@ openerp.mail = function (session) {
domains: domains || [], domains: domains || [],
contexts: contexts || [], contexts: contexts || [],
group_by_seq: groupbys || [] group_by_seq: groupbys || []
}).then(function (results) { }).done(function (results) {
self.search_results['context'] = results.context; self.search_results['context'] = results.context;
self.search_results['domain'] = results.domain; self.search_results['domain'] = results.domain;
self.root.destroy(); self.root.destroy();

View File

@ -85,7 +85,7 @@ openerp_mail_followers = function(session, mail) {
read_value: function () { read_value: function () {
var self = this; var self = this;
return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).then(function (results) {
self.set_value(results[0].message_follower_ids); self.set_value(results[0].message_follower_ids);
}); });
}, },
@ -98,9 +98,9 @@ openerp_mail_followers = function(session, mail) {
fetch_followers: function (value_) { fetch_followers: function (value_) {
this.value = value_ || {}; this.value = value_ || {};
return this.ds_follow.call('read', [this.value, ['name', 'user_ids']]) return this.ds_follow.call('read', [this.value, ['name', 'user_ids']])
.pipe(this.proxy('display_followers'), this.proxy('fetch_generic')) .then(this.proxy('display_followers'), this.proxy('fetch_generic'))
.pipe(this.proxy('display_buttons')) .then(this.proxy('display_buttons'))
.pipe(this.proxy('fetch_subtypes')); .then(this.proxy('fetch_subtypes'));
}, },
/** Read on res.partner failed: fall back on a generic case /** Read on res.partner failed: fall back on a generic case
@ -109,10 +109,10 @@ openerp_mail_followers = function(session, mail) {
fetch_generic: function (error, event) { fetch_generic: function (error, event) {
var self = this; var self = this;
event.preventDefault(); event.preventDefault();
return this.ds_users.call('read', [this.session.uid, ['partner_id']]).pipe(function (results) { return this.ds_users.call('read', [this.session.uid, ['partner_id']]).then(function (results) {
var pid = results['partner_id'][0]; var pid = results['partner_id'][0];
self.message_is_follower = (_.indexOf(self.get('value'), pid) != -1); self.message_is_follower = (_.indexOf(self.get('value'), pid) != -1);
}).pipe(self.proxy('display_generic')); }).then(self.proxy('display_generic'));
}, },
_format_followers: function(count){ _format_followers: function(count){
// TDE note: why redefining _t ? // TDE note: why redefining _t ?
@ -179,7 +179,7 @@ openerp_mail_followers = function(session, mail) {
var subtype_list_ul = this.$('.oe_subtype_list').empty(); var subtype_list_ul = this.$('.oe_subtype_list').empty();
if (! this.message_is_follower) return; if (! this.message_is_follower) return;
var context = new session.web.CompoundContext(this.build_context(), {}); var context = new session.web.CompoundContext(this.build_context(), {});
this.ds_model.call('message_get_subscription_data', [[this.view.datarecord.id], context]).pipe(this.proxy('display_subtypes')); this.ds_model.call('message_get_subscription_data', [[this.view.datarecord.id], context]).then(this.proxy('display_subtypes'));
}, },
/** Display subtypes: {'name': default, followed} */ /** Display subtypes: {'name': default, followed} */
@ -206,7 +206,7 @@ openerp_mail_followers = function(session, mail) {
$(record).attr('checked',false); $(record).attr('checked',false);
}); });
var context = new session.web.CompoundContext(this.build_context(), {}); var context = new session.web.CompoundContext(this.build_context(), {});
return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]).pipe(this.proxy('read_value')); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]).then(this.proxy('read_value'));
}, },
do_update_subscription: function (event) { do_update_subscription: function (event) {
@ -221,7 +221,7 @@ openerp_mail_followers = function(session, mail) {
var context = new session.web.CompoundContext(this.build_context(), {}); var context = new session.web.CompoundContext(this.build_context(), {});
return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], this.message_is_follower ? checklist:undefined, context]) return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], this.message_is_follower ? checklist:undefined, context])
.pipe(this.proxy('read_value')); .then(this.proxy('read_value'));
}, },
}); });
}; };

View File

@ -12,7 +12,7 @@ openerp.pad = function(instance) {
model: self.view.model, model: self.view.model,
field_name: self.name, field_name: self.name,
object_id: self.view.datarecord.id object_id: self.view.datarecord.id
}}).then(function(data) { }}).done(function(data) {
if(data&&data.url){ if(data&&data.url){
_super(data.url); _super(data.url);
self.renderElement(); self.renderElement();

View File

@ -37,12 +37,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
callbacks[i](params); callbacks[i](params);
} }
this.connection.rpc('/pos/'+name, params || {}).then(function(result){ this.connection.rpc('/pos/' + name, params || {}).done(function(result) {
ret.resolve(result); ret.resolve(result);
}, }).fail(function(error) {
function(error){ ret.reject(error);
ret.reject(error); });
});
return ret; return ret;
}, },
@ -96,7 +95,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
return this.weight; return this.weight;
}else{ }else{
this.message('weighting_read_kg',{}) this.message('weighting_read_kg',{})
.then(function(weight){ .done(function(weight){
if(self.weighting && !self.bypass_proxy){ if(self.weighting && !self.bypass_proxy){
self.weight = weight; self.weight = weight;
} }

View File

@ -59,10 +59,10 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
// Any change on this data made on the server is thus not reflected on the point of sale until it is relaunched. // Any change on this data made on the server is thus not reflected on the point of sale until it is relaunched.
// when all the data has loaded, we compute some stuff, and declare the Pos ready to be used. // when all the data has loaded, we compute some stuff, and declare the Pos ready to be used.
$.when(this.load_server_data()) $.when(this.load_server_data())
.then(function(){ .done(function(){
//self.log_loaded_data(); //Uncomment if you want to log the data to the console for easier debugging //self.log_loaded_data(); //Uncomment if you want to log the data to the console for easier debugging
self.ready.resolve(); self.ready.resolve();
},function(){ }).fail(function(){
//we failed to load some backend data, or the backend was badly configured. //we failed to load some backend data, or the backend was badly configured.
//the error messages will be displayed in PosWidget //the error messages will be displayed in PosWidget
self.ready.reject(); self.ready.reject();
@ -78,7 +78,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
var self = this; var self = this;
var loaded = self.fetch('res.users',['name','company_id'],[['id','=',this.session.uid]]) var loaded = self.fetch('res.users',['name','company_id'],[['id','=',this.session.uid]])
.pipe(function(users){ .then(function(users){
self.set('user',users[0]); self.set('user',users[0]);
return self.fetch('res.company', return self.fetch('res.company',
@ -93,19 +93,19 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'partner_id', 'partner_id',
], ],
[['id','=',users[0].company_id[0]]]); [['id','=',users[0].company_id[0]]]);
}).pipe(function(companies){ }).then(function(companies){
self.set('company',companies[0]); self.set('company',companies[0]);
return self.fetch('res.partner',['contact_address'],[['id','=',companies[0].partner_id[0]]]); return self.fetch('res.partner',['contact_address'],[['id','=',companies[0].partner_id[0]]]);
}).pipe(function(company_partners){ }).then(function(company_partners){
self.get('company').contact_address = company_partners[0].contact_address; self.get('company').contact_address = company_partners[0].contact_address;
return self.fetch('res.currency',['symbol','position'],[['id','=',self.get('company').currency_id[0]]]); return self.fetch('res.currency',['symbol','position'],[['id','=',self.get('company').currency_id[0]]]);
}).pipe(function(currencies){ }).then(function(currencies){
self.set('currency',currencies[0]); self.set('currency',currencies[0]);
return self.fetch('product.uom', null, null); return self.fetch('product.uom', null, null);
}).pipe(function(units){ }).then(function(units){
self.set('units',units); self.set('units',units);
var units_by_id = {}; var units_by_id = {};
for(var i = 0, len = units.length; i < len; i++){ for(var i = 0, len = units.length; i < len; i++){
@ -114,15 +114,15 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
self.set('units_by_id',units_by_id); self.set('units_by_id',units_by_id);
return self.fetch('product.packaging', null, null); return self.fetch('product.packaging', null, null);
}).pipe(function(packagings){ }).then(function(packagings){
self.set('product.packaging',packagings); self.set('product.packaging',packagings);
return self.fetch('res.users', ['name','ean13'], [['ean13', '!=', false]]); return self.fetch('res.users', ['name','ean13'], [['ean13', '!=', false]]);
}).pipe(function(users){ }).then(function(users){
self.set('user_list',users); self.set('user_list',users);
return self.fetch('account.tax', ['amount', 'price_include', 'type']); return self.fetch('account.tax', ['amount', 'price_include', 'type']);
}).pipe(function(taxes){ }).then(function(taxes){
self.set('taxes', taxes); self.set('taxes', taxes);
return self.fetch( return self.fetch(
@ -130,7 +130,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
['id', 'journal_ids','name','user_id','config_id','start_at','stop_at'], ['id', 'journal_ids','name','user_id','config_id','start_at','stop_at'],
[['state', '=', 'opened'], ['user_id', '=', self.session.uid]] [['state', '=', 'opened'], ['user_id', '=', self.session.uid]]
); );
}).pipe(function(sessions){ }).then(function(sessions){
self.set('pos_session', sessions[0]); self.set('pos_session', sessions[0]);
return self.fetch( return self.fetch(
@ -141,7 +141,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'iface_print_via_proxy','iface_cashdrawer','state','sequence_id','session_ids'], 'iface_print_via_proxy','iface_cashdrawer','state','sequence_id','session_ids'],
[['id','=', self.get('pos_session').config_id[0]]] [['id','=', self.get('pos_session').config_id[0]]]
); );
}).pipe(function(configs){ }).then(function(configs){
var pos_config = configs[0]; var pos_config = configs[0];
self.set('pos_config', pos_config); self.set('pos_config', pos_config);
self.iface_electronic_scale = !!pos_config.iface_electronic_scale; self.iface_electronic_scale = !!pos_config.iface_electronic_scale;
@ -151,15 +151,15 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
self.iface_cashdrawer = !!pos_config.iface_cashdrawer; self.iface_cashdrawer = !!pos_config.iface_cashdrawer;
return self.fetch('sale.shop',[],[['id','=',pos_config.shop_id[0]]]); return self.fetch('sale.shop',[],[['id','=',pos_config.shop_id[0]]]);
}).pipe(function(shops){ }).then(function(shops){
self.set('shop',shops[0]); self.set('shop',shops[0]);
return self.fetch('product.packaging',['ean','product_id']); return self.fetch('product.packaging',['ean','product_id']);
}).pipe(function(packagings){ }).then(function(packagings){
self.db.add_packagings(packagings); self.db.add_packagings(packagings);
return self.fetch('pos.category', ['id','name','parent_id','child_id','image']) return self.fetch('pos.category', ['id','name','parent_id','child_id','image'])
}).pipe(function(categories){ }).then(function(categories){
self.db.add_categories(categories); self.db.add_categories(categories);
return self.fetch( return self.fetch(
@ -169,7 +169,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
[['pos_categ_id','!=', false],['sale_ok','=',true]], [['pos_categ_id','!=', false],['sale_ok','=',true]],
{pricelist: self.get('shop').pricelist_id[0]} // context for price {pricelist: self.get('shop').pricelist_id[0]} // context for price
); );
}).pipe(function(products){ }).then(function(products){
self.db.add_products(products); self.db.add_products(products);
return self.fetch( return self.fetch(
@ -177,11 +177,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
['account_id','currency','journal_id','state','name','user_id','pos_session_id'], ['account_id','currency','journal_id','state','name','user_id','pos_session_id'],
[['state','=','open'],['pos_session_id', '=', self.get('pos_session').id]] [['state','=','open'],['pos_session_id', '=', self.get('pos_session').id]]
); );
}).pipe(function(bank_statements){ }).then(function(bank_statements){
self.set('bank_statements', bank_statements); self.set('bank_statements', bank_statements);
return self.fetch('account.journal', undefined, [['user_id','=', self.get('pos_session').user_id[0]]]); return self.fetch('account.journal', undefined, [['user_id','=', self.get('pos_session').user_id[0]]]);
}).pipe(function(journals){ }).then(function(journals){
self.set('journals',journals); self.set('journals',journals);
// associate the bank statements with their journals. // associate the bank statements with their journals.

View File

@ -557,7 +557,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
setTimeout(function(){ setTimeout(function(){
var def = job.fun(); var def = job.fun();
if(def){ if(def){
def.then(run); def.done(run);
}else{ }else{
run(); run();
} }
@ -615,7 +615,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var def = new $.Deferred(); var def = new $.Deferred();
console.log("START"); console.log("START");
self.pos.proxy.payment_request(self.pos.get('selectedOrder').getDueLeft()) self.pos.proxy.payment_request(self.pos.get('selectedOrder').getDueLeft())
.then(function(ack){ .done(function(ack){
if(ack === 'ok'){ if(ack === 'ok'){
self.queue.schedule(self.update); self.queue.schedule(self.update);
}else if(ack.indexOf('error') === 0){ }else if(ack.indexOf('error') === 0){
@ -638,7 +638,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
return def.resolve(); return def.resolve();
} }
self.pos.proxy.payment_status() self.pos.proxy.payment_status()
.then(function(status){ .done(function(status){
if(status.status === 'paid'){ if(status.status === 'paid'){
var currentOrder = self.pos.get('selectedOrder'); var currentOrder = self.pos.get('selectedOrder');

View File

@ -810,7 +810,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
start: function() { start: function() {
var self = this; var self = this;
return self.pos.ready.then(function() { return self.pos.ready.done(function() {
self.build_currency_template(); self.build_currency_template();
self.renderElement(); self.renderElement();
@ -849,7 +849,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
self.$('.loader').animate({opacity:0},1500,'swing',function(){self.$('.loader').hide();}); self.$('.loader').animate({opacity:0},1500,'swing',function(){self.$('.loader').hide();});
self.$('.loader img').hide(); self.$('.loader img').hide();
},function(){ // error when loading models data from the backend }).fail(function(){ // error when loading models data from the backend
self.$('.loader img').hide(); self.$('.loader img').hide();
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_session_opening']], ['res_id']) return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_session_opening']], ['res_id'])
.pipe( _.bind(function(res){ .pipe( _.bind(function(res){

View File

@ -20,7 +20,7 @@ instance.web.ViewManager.include({
if(this.active_view == 'form') { if(this.active_view == 'form') {
this.record_id = this.views[this.active_view].controller.datarecord.id; this.record_id = this.views[this.active_view].controller.datarecord.id;
} }
this.process_get_object().pipe(function(process) { this.process_get_object().then(function(process) {
if(process && process.length) { if(process && process.length) {
if(process.length > 1) { if(process.length > 1) {
self.process_selection = process; self.process_selection = process;
@ -30,7 +30,7 @@ instance.web.ViewManager.include({
} }
} }
return $.Deferred().resolve(); return $.Deferred().resolve();
}).pipe(function() { }).then(function() {
var def = $.Deferred(); var def = $.Deferred();
if(self.process_id) { if(self.process_id) {
$.when(self.process_graph_get()).done(function(res) { $.when(self.process_graph_get()).done(function(res) {
@ -221,12 +221,12 @@ instance.web.ViewManager.include({
var dataset = new instance.web.DataSet(this, 'ir.values', this.session.user_context); var dataset = new instance.web.DataSet(this, 'ir.values', this.session.user_context);
var action_manager = new instance.web.ActionManager(self); var action_manager = new instance.web.ActionManager(self);
dataset.call('get', dataset.call('get',
['action', 'tree_but_open',[['ir.ui.menu', id]], dataset.context]).then(function(res) { ['action', 'tree_but_open',[['ir.ui.menu', id]], dataset.context]).done(function(res) {
var action = res[0][res[0].length - 1]; var action = res[0][res[0].length - 1];
self.rpc("/web/action/load", { self.rpc("/web/action/load", {
action_id: action.id, action_id: action.id,
context: dataset.context context: dataset.context
}).then(function(result) { }).done(function(result) {
action_manager.replace(self.$el); action_manager.replace(self.$el);
action_manager.do_action(result.result); action_manager.do_action(result.result);
}) })

View File

@ -16,7 +16,7 @@ openerp.project = function(openerp) {
// Find their matching names // Find their matching names
var dataset = new openerp.web.DataSetSearch(self, 'res.users', self.session.context, [['id', 'in', _.uniq(members_ids)]]); var dataset = new openerp.web.DataSetSearch(self, 'res.users', self.session.context, [['id', 'in', _.uniq(members_ids)]]);
dataset.read_slice(['id', 'name']).then(function(result) { dataset.read_slice(['id', 'name']).done(function(result) {
_.each(result, function(v, k) { _.each(result, function(v, k) {
// Set the proper value in the DOM // Set the proper value in the DOM
self.$el.find('img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({ self.$el.find('img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({
@ -41,7 +41,7 @@ openerp.project = function(openerp) {
// Find their matching names // Find their matching names
var dataset = new openerp.web.DataSetSearch(self, 'project.category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]); var dataset = new openerp.web.DataSetSearch(self, 'project.category', self.session.context, [['id', 'in', _.uniq(categ_ids)]]);
dataset.read_slice(['id', 'name']).then(function(result) { dataset.read_slice(['id', 'name']).done(function(result) {
_.each(result, function(v, k) { _.each(result, function(v, k) {
// Set the proper value in the DOM and display the element // Set the proper value in the DOM and display the element
self.$el.find('span[data-categ_id=' + v.id + ']').text(v.name); self.$el.find('span[data-categ_id=' + v.id + ']').text(v.name);

View File

@ -15,7 +15,7 @@ openerp.share = function(session) {
self.rpc('/web/session/eval_domain_and_context', { self.rpc('/web/session/eval_domain_and_context', {
domains: [domain], domains: [domain],
contexts: [view.dataset.context] contexts: [view.dataset.context]
}).then(function (result) { }).done(function (result) {
Share.create({ Share.create({
name: action.name, name: action.name,
record_name: rec_name, record_name: rec_name,
@ -24,8 +24,8 @@ openerp.share = function(session) {
user_type: user_type || 'embedded', user_type: user_type || 'embedded',
view_type: view.fields_view.type, view_type: view.fields_view.type,
invite: invite || false, invite: invite || false,
}).then(function(share_id) { }).done(function(share_id) {
var step1 = Share.call('go_step_1', [[share_id]]).then(function(result) { var step1 = Share.call('go_step_1', [[share_id]]).done(function(result) {
var action = result; var action = result;
self.do_action(action); self.do_action(action);
}); });
@ -37,7 +37,7 @@ openerp.share = function(session) {
if (!session.session.share_flag) { if (!session.session.share_flag) {
session.session.share_flag = $.Deferred(function() { session.session.share_flag = $.Deferred(function() {
var func = new session.web.Model("share.wizard").get_func("has_share"); var func = new session.web.Model("share.wizard").get_func("has_share");
func(session.session.uid).pipe(function(res) { func(session.session.uid).then(function(res) {
if(res) { if(res) {
session.session.share_flag.resolve(); session.session.share_flag.resolve();
} else { } else {

View File

@ -14,7 +14,7 @@ openerp.web_linkedin = function(instance) {
}, },
test_linkedin: function() { test_linkedin: function() {
var self = this; var self = this;
return this.test_api_key().pipe(function() { return this.test_api_key().then(function() {
if (self.linkedin_added) if (self.linkedin_added)
return self.linkedin_def.promise(); return self.linkedin_def.promise();
var tag = document.createElement('script'); var tag = document.createElement('script');
@ -37,7 +37,7 @@ openerp.web_linkedin = function(instance) {
if (this.api_key) { if (this.api_key) {
return $.when(); return $.when();
} }
return new instance.web.Model("ir.config_parameter").call("get_param", ["web.linkedin.apikey"]).pipe(function(a) { return new instance.web.Model("ir.config_parameter").call("get_param", ["web.linkedin.apikey"]).then(function(a) {
if (!!a) { if (!!a) {
self.api_key = a; self.api_key = a;
return true; return true;
@ -69,13 +69,13 @@ openerp.web_linkedin = function(instance) {
}, },
search_linkedin: function() { search_linkedin: function() {
var self = this; var self = this;
this.display_dm.add(instance.web_linkedin.tester.test_linkedin()).then(function() { this.display_dm.add(instance.web_linkedin.tester.test_linkedin()).done(function() {
var pop = new instance.web_linkedin.LinkedinPopup(self, self.get("value")); var pop = new instance.web_linkedin.LinkedinPopup(self, self.get("value"));
pop.open(); pop.open();
pop.on("selected", this, function(entity) { pop.on("selected", this, function(entity) {
self.selected_entity(entity); self.selected_entity(entity);
}); });
}, _.bind(this.linkedin_disabled, this)); }).fail(_.bind(this.linkedin_disabled, this));
}, },
linkedin_disabled: function() { linkedin_disabled: function() {
instance.web.dialog($(QWeb.render("LinkedIn.DisabledWarning")), { instance.web.dialog($(QWeb.render("LinkedIn.DisabledWarning")), {
@ -87,7 +87,7 @@ openerp.web_linkedin = function(instance) {
}, },
selected_entity: function(entity) { selected_entity: function(entity) {
var self = this; var self = this;
this.create_on_change(entity).then(function(to_change) { this.create_on_change(entity).done(function(to_change) {
self.view.set_values(to_change); self.view.set_values(to_change);
}); });
}, },
@ -101,7 +101,7 @@ openerp.web_linkedin = function(instance) {
to_change.image = false; to_change.image = false;
if (entity.logoUrl) { if (entity.logoUrl) {
defs.push(self.rpc('/web_linkedin/binary/url2binary', defs.push(self.rpc('/web_linkedin/binary/url2binary',
{'url': entity.logoUrl}).pipe(function(data){ {'url': entity.logoUrl}).then(function(data){
to_change.image = data; to_change.image = data;
})); }));
} }
@ -120,7 +120,7 @@ openerp.web_linkedin = function(instance) {
}).error(function() { }).error(function() {
children_def.reject(); children_def.reject();
}); });
defs.push(children_def.pipe(function(result) { defs.push(children_def.then(function(result) {
result = _.reject(result.people.values || [], function(el) { result = _.reject(result.people.values || [], function(el) {
return ! el.formattedName; return ! el.formattedName;
}); });
@ -128,7 +128,7 @@ openerp.web_linkedin = function(instance) {
el.__type = "people"; el.__type = "people";
return self.create_on_change(el); return self.create_on_change(el);
}); });
return $.when.apply($, defs).pipe(function() { return $.when.apply($, defs).then(function() {
var p_to_change = _.toArray(arguments); var p_to_change = _.toArray(arguments);
to_change.child_ids = p_to_change; to_change.child_ids = p_to_change;
}); });
@ -144,7 +144,7 @@ openerp.web_linkedin = function(instance) {
to_change.image = false; to_change.image = false;
if (entity.pictureUrl) { if (entity.pictureUrl) {
defs.push(self.rpc('/web_linkedin/binary/url2binary', defs.push(self.rpc('/web_linkedin/binary/url2binary',
{'url': entity.pictureUrl}).pipe(function(data){ {'url': entity.pictureUrl}).then(function(data){
to_change.image = data; to_change.image = data;
})); }));
} }
@ -163,7 +163,7 @@ openerp.web_linkedin = function(instance) {
to_change.linkedinUrl = entity.publicProfileUrl; to_change.linkedinUrl = entity.publicProfileUrl;
*/ */
} }
return $.when.apply($, defs).pipe(function() { return $.when.apply($, defs).then(function() {
return to_change; return to_change;
}); });
}, },
@ -186,7 +186,7 @@ openerp.web_linkedin = function(instance) {
this._super(); this._super();
var self = this; var self = this;
this.on("authentified", this, this.authentified); this.on("authentified", this, this.authentified);
instance.web_linkedin.tester.test_authentication().then(function() { instance.web_linkedin.tester.test_authentication().done(function() {
self.trigger("authentified"); self.trigger("authentified");
}); });
}, },
@ -200,7 +200,7 @@ openerp.web_linkedin = function(instance) {
encodeURI(this.text), this.limit)).result(function (result) { encodeURI(this.text), this.limit)).result(function (result) {
cdef.resolve(result); cdef.resolve(result);
}); });
var def = cdef.pipe(function(companies) { var def = cdef.then(function(companies) {
var lst = companies.companies.values || []; var lst = companies.companies.values || [];
lst = _.first(lst, self.limit); lst = _.first(lst, self.limit);
lst = _.map(lst, function(el) { lst = _.map(lst, function(el) {
@ -214,7 +214,7 @@ openerp.web_linkedin = function(instance) {
params({"keywords": this.text, "count": this.limit}).result(function(result) { params({"keywords": this.text, "count": this.limit}).result(function(result) {
pdef.resolve(result); pdef.resolve(result);
}); });
var def2 = pdef.pipe(function(people) { var def2 = pdef.then(function(people) {
var plst = people.people.values || []; var plst = people.people.values || [];
plst = _.first(plst, self.limit); plst = _.first(plst, self.limit);
plst = _.map(plst, function(el) { plst = _.map(plst, function(el) {

View File

@ -46,7 +46,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
load: function() { load: function() {
var self = this; var self = this;
this.$el.find('.oe_systray_shortcuts_items').empty(); this.$el.find('.oe_systray_shortcuts_items').empty();
return this.rpc('/web/shortcuts/list', {}).then(function(shortcuts) { return this.rpc('/web/shortcuts/list', {}).done(function(shortcuts) {
_.each(shortcuts, function(sc) { _.each(shortcuts, function(sc) {
self.trigger('display', sc); self.trigger('display', sc);
}); });
@ -80,7 +80,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
id = $link.data('id'); id = $link.data('id');
self.session.active_id = id; self.session.active_id = id;
// TODO: Use do_action({menu_id: id, type: 'ir.actions.menu'}) // TODO: Use do_action({menu_id: id, type: 'ir.actions.menu'})
self.rpc('/web/menu/action', {'menu_id': id}).then(function(ir_menu_data) { self.rpc('/web/menu/action', {'menu_id': id}).done(function(ir_menu_data) {
if (ir_menu_data.action.length){ if (ir_menu_data.action.length){
instance.webclient.on_menu_action({action_id: ir_menu_data.action[0][2].id}); instance.webclient.on_menu_action({action_id: ir_menu_data.action[0][2].id});
} }
@ -96,7 +96,7 @@ instance.web.UserMenu.include({
do_update: function() { do_update: function() {
var self = this; var self = this;
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.update_promise.then(function() { this.update_promise.done(function() {
if (self.shortcuts) { if (self.shortcuts) {
self.shortcuts.trigger('load'); self.shortcuts.trigger('load');
} else { } else {
@ -110,7 +110,7 @@ instance.web.UserMenu.include({
instance.web.ViewManagerAction.include({ instance.web.ViewManagerAction.include({
switch_mode: function (view_type, no_store) { switch_mode: function (view_type, no_store) {
var self = this; var self = this;
this._super.apply(this, arguments).then(function() { this._super.apply(this, arguments).done(function() {
self.shortcut_check(self.views[view_type]); self.shortcut_check(self.views[view_type]);
}); });
}, },