[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.old_search = _.bind(this._super, this);
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;
self.partners = result;
var index = _.find(_.range(self.partners.length), function(el) {
@ -74,7 +74,7 @@ openerp.account = function (instance) {
return fct();
} else {
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 =
instance.web.format_value(res.last_reconciliation_date, {"type": "datetime"}, _t("Never"));
return fct();
@ -92,7 +92,7 @@ openerp.account = function (instance) {
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({
active_id: ids[0],
active_ids: ids,
@ -101,7 +101,7 @@ openerp.account = function (instance) {
return self.rpc("/web/action/load", {
action_id: result[1],
context: additional_context
}).then(function (result) {
}).done(function (result) {
result.context = _.extend(result.context || {}, additional_context);
result.flags = result.flags || {};
result.flags.new_window = true;
@ -116,7 +116,7 @@ openerp.account = function (instance) {
mark_as_reconciled: function() {
var self = this;
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);
});
},

View File

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

View File

@ -12,7 +12,7 @@ openerp.auth_oauth = function(instance) {
} else if(this.params.oauth_error === 2) {
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([]);
});
},
@ -23,7 +23,7 @@ openerp.auth_oauth = function(instance) {
do_oauth_load: function() {
var db = this.$("form [name=db]").val();
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) {

View File

@ -69,7 +69,7 @@ instance.web.Login = instance.web.Login.extend({
_check_error: function() {
var self = this;
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) {
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) {
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) {
self.do_warn(result.title, result.error);
return;

View File

@ -139,7 +139,7 @@ openerp.base_import = function (instance) {
this._super(),
this.Import.call('create', [{
'res_model': this.res_model
}]).then(function (id) {
}]).done(function (id) {
self.id = 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.Import.call(
'parse_preview', [this.id, this.import_options()])
.then(function (result) {
.done(function (result) {
var signal = result.error ? 'preview_failed' : 'preview_succeeded';
self[signal](result);
});
@ -337,11 +337,11 @@ openerp.base_import = function (instance) {
},
onvalidate: function () {
return this.call_import({ dryrun: true })
.then(this.proxy('validated'));
.done(this.proxy('validated'));
},
onimport: function () {
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) {
return message.type === 'error' })) {
self['import_succeeded']();

View File

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

View File

@ -15,7 +15,7 @@ openerp.edi.EdiView = openerp.web.Widget.extend({
this._super();
var self = this;
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){
this.doc = docs[0];
@ -108,7 +108,7 @@ openerp.edi.EdiView = openerp.web.Widget.extend({
});
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'));
});
}
@ -149,11 +149,11 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
},
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) {
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);
});
}
@ -188,7 +188,7 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
});
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'));
});
}

View File

@ -20,9 +20,9 @@ var _t = instance.web._t;
on_google_doc: function() {
var self = this;
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);
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') {
var params = {
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, [
['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) )
return;
if (res[0].attendance_access == false){
@ -75,7 +75,7 @@ openerp.hr_attendance = function (instance) {
do_update: function () {
this._super();
var self = this;
this.update_promise = this.update_promise.then(function () {
this.update_promise = this.update_promise.done(function () {
if (self.attendanceslider)
return;
self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self);

View File

@ -16,7 +16,7 @@ openerp.hr_recruitment = function(openerp) {
// Find their matching names
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) {
// Set the proper value in the DOM and display the element
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");
this.res_o2m_drop.add(new instance.web.Model(this.view.model).call("resolve_2many_commands", ["timesheet_ids", commands, [],
new instance.web.CompoundContext()]))
.then(function(result) {
.done(function(result) {
self.querying = true;
self.set({sheets: result});
self.querying = false;
@ -57,7 +57,7 @@ openerp.hr_timesheet_sheet = function(instance) {
if (self.querying)
return;
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;
});
},
@ -85,7 +85,7 @@ openerp.hr_timesheet_sheet = function(instance) {
var 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'],
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;
// calculating 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) });
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) {
account_defaults = _.extend({}, default_get, accounts_defaults[account_id]);
// group by days
@ -136,7 +136,7 @@ openerp.hr_timesheet_sheet = function(instance) {
// we need the name_get of the analytic accounts
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 = {};
_.each(result, function(el) {
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
self.dates = dates;
self.accounts = accounts;
@ -222,7 +222,7 @@ openerp.hr_timesheet_sheet = function(instance) {
return;
}
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, {
name: self.description_line,
unit_amount: 0,

View File

@ -356,7 +356,7 @@ openerp.mail = function (session) {
this.context.default_parent_id,
attachments,
this.parent_thread.context
]).then(function (record) {
]).done(function (record) {
var thread = self.parent_thread;
// create object and attach to the thread object
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
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.to_read = !self.to_read;
});
@ -801,7 +801,7 @@ openerp.mail = function (session) {
on_vote: function (event) {
event.stopPropagation();
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.vote_nb += self.has_voted ? 1 : -1;
self.display_vote();
@ -826,7 +826,7 @@ openerp.mail = function (session) {
event.stopPropagation();
var self=this;
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;
if (self.is_favorite) {
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;
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) {
var self = this;
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);
});
},
@ -1596,7 +1596,7 @@ openerp.mail = function (session) {
domains: domains || [],
contexts: contexts || [],
group_by_seq: groupbys || []
}).then(function (results) {
}).done(function (results) {
self.search_results['context'] = results.context;
self.search_results['domain'] = results.domain;
self.root.destroy();

View File

@ -85,7 +85,7 @@ openerp_mail_followers = function(session, mail) {
read_value: function () {
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);
});
},
@ -98,9 +98,9 @@ openerp_mail_followers = function(session, mail) {
fetch_followers: function (value_) {
this.value = value_ || {};
return this.ds_follow.call('read', [this.value, ['name', 'user_ids']])
.pipe(this.proxy('display_followers'), this.proxy('fetch_generic'))
.pipe(this.proxy('display_buttons'))
.pipe(this.proxy('fetch_subtypes'));
.then(this.proxy('display_followers'), this.proxy('fetch_generic'))
.then(this.proxy('display_buttons'))
.then(this.proxy('fetch_subtypes'));
},
/** 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) {
var self = this;
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];
self.message_is_follower = (_.indexOf(self.get('value'), pid) != -1);
}).pipe(self.proxy('display_generic'));
}).then(self.proxy('display_generic'));
},
_format_followers: function(count){
// TDE note: why redefining _t ?
@ -179,7 +179,7 @@ openerp_mail_followers = function(session, mail) {
var subtype_list_ul = this.$('.oe_subtype_list').empty();
if (! this.message_is_follower) return;
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} */
@ -206,7 +206,7 @@ openerp_mail_followers = function(session, mail) {
$(record).attr('checked',false);
});
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) {
@ -221,7 +221,7 @@ openerp_mail_followers = function(session, mail) {
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])
.pipe(this.proxy('read_value'));
.then(this.proxy('read_value'));
},
});
};

View File

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

View File

@ -37,12 +37,11 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
callbacks[i](params);
}
this.connection.rpc('/pos/'+name, params || {}).then(function(result){
ret.resolve(result);
},
function(error){
ret.reject(error);
});
this.connection.rpc('/pos/' + name, params || {}).done(function(result) {
ret.resolve(result);
}).fail(function(error) {
ret.reject(error);
});
return ret;
},
@ -96,7 +95,7 @@ function openerp_pos_devices(instance,module){ //module is instance.point_of_sal
return this.weight;
}else{
this.message('weighting_read_kg',{})
.then(function(weight){
.done(function(weight){
if(self.weighting && !self.bypass_proxy){
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.
// when all the data has loaded, we compute some stuff, and declare the Pos ready to be used.
$.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.ready.resolve();
},function(){
}).fail(function(){
//we failed to load some backend data, or the backend was badly configured.
//the error messages will be displayed in PosWidget
self.ready.reject();
@ -78,7 +78,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
var self = this;
var loaded = self.fetch('res.users',['name','company_id'],[['id','=',this.session.uid]])
.pipe(function(users){
.then(function(users){
self.set('user',users[0]);
return self.fetch('res.company',
@ -93,19 +93,19 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'partner_id',
],
[['id','=',users[0].company_id[0]]]);
}).pipe(function(companies){
}).then(function(companies){
self.set('company',companies[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;
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]);
return self.fetch('product.uom', null, null);
}).pipe(function(units){
}).then(function(units){
self.set('units',units);
var units_by_id = {};
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);
return self.fetch('product.packaging', null, null);
}).pipe(function(packagings){
}).then(function(packagings){
self.set('product.packaging',packagings);
return self.fetch('res.users', ['name','ean13'], [['ean13', '!=', false]]);
}).pipe(function(users){
}).then(function(users){
self.set('user_list',users);
return self.fetch('account.tax', ['amount', 'price_include', 'type']);
}).pipe(function(taxes){
}).then(function(taxes){
self.set('taxes', taxes);
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'],
[['state', '=', 'opened'], ['user_id', '=', self.session.uid]]
);
}).pipe(function(sessions){
}).then(function(sessions){
self.set('pos_session', sessions[0]);
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'],
[['id','=', self.get('pos_session').config_id[0]]]
);
}).pipe(function(configs){
}).then(function(configs){
var pos_config = configs[0];
self.set('pos_config', pos_config);
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;
return self.fetch('sale.shop',[],[['id','=',pos_config.shop_id[0]]]);
}).pipe(function(shops){
}).then(function(shops){
self.set('shop',shops[0]);
return self.fetch('product.packaging',['ean','product_id']);
}).pipe(function(packagings){
}).then(function(packagings){
self.db.add_packagings(packagings);
return self.fetch('pos.category', ['id','name','parent_id','child_id','image'])
}).pipe(function(categories){
}).then(function(categories){
self.db.add_categories(categories);
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]],
{pricelist: self.get('shop').pricelist_id[0]} // context for price
);
}).pipe(function(products){
}).then(function(products){
self.db.add_products(products);
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'],
[['state','=','open'],['pos_session_id', '=', self.get('pos_session').id]]
);
}).pipe(function(bank_statements){
}).then(function(bank_statements){
self.set('bank_statements', bank_statements);
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);
// 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(){
var def = job.fun();
if(def){
def.then(run);
def.done(run);
}else{
run();
}
@ -615,7 +615,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var def = new $.Deferred();
console.log("START");
self.pos.proxy.payment_request(self.pos.get('selectedOrder').getDueLeft())
.then(function(ack){
.done(function(ack){
if(ack === 'ok'){
self.queue.schedule(self.update);
}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();
}
self.pos.proxy.payment_status()
.then(function(status){
.done(function(status){
if(status.status === 'paid'){
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() {
var self = this;
return self.pos.ready.then(function() {
return self.pos.ready.done(function() {
self.build_currency_template();
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 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();
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_session_opening']], ['res_id'])
.pipe( _.bind(function(res){

View File

@ -20,7 +20,7 @@ instance.web.ViewManager.include({
if(this.active_view == 'form') {
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.length > 1) {
self.process_selection = process;
@ -30,7 +30,7 @@ instance.web.ViewManager.include({
}
}
return $.Deferred().resolve();
}).pipe(function() {
}).then(function() {
var def = $.Deferred();
if(self.process_id) {
$.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 action_manager = new instance.web.ActionManager(self);
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];
self.rpc("/web/action/load", {
action_id: action.id,
context: dataset.context
}).then(function(result) {
}).done(function(result) {
action_manager.replace(self.$el);
action_manager.do_action(result.result);
})

View File

@ -16,7 +16,7 @@ openerp.project = function(openerp) {
// Find their matching names
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) {
// Set the proper value in the DOM
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
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) {
// Set the proper value in the DOM and display the element
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', {
domains: [domain],
contexts: [view.dataset.context]
}).then(function (result) {
}).done(function (result) {
Share.create({
name: action.name,
record_name: rec_name,
@ -24,8 +24,8 @@ openerp.share = function(session) {
user_type: user_type || 'embedded',
view_type: view.fields_view.type,
invite: invite || false,
}).then(function(share_id) {
var step1 = Share.call('go_step_1', [[share_id]]).then(function(result) {
}).done(function(share_id) {
var step1 = Share.call('go_step_1', [[share_id]]).done(function(result) {
var action = result;
self.do_action(action);
});
@ -37,7 +37,7 @@ openerp.share = function(session) {
if (!session.session.share_flag) {
session.session.share_flag = $.Deferred(function() {
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) {
session.session.share_flag.resolve();
} else {

View File

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

View File

@ -46,7 +46,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
load: function() {
var self = this;
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) {
self.trigger('display', sc);
});
@ -80,7 +80,7 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
id = $link.data('id');
self.session.active_id = id;
// 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){
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() {
var self = this;
this._super.apply(this, arguments);
this.update_promise.then(function() {
this.update_promise.done(function() {
if (self.shortcuts) {
self.shortcuts.trigger('load');
} else {
@ -110,7 +110,7 @@ instance.web.UserMenu.include({
instance.web.ViewManagerAction.include({
switch_mode: function (view_type, no_store) {
var self = this;
this._super.apply(this, arguments).then(function() {
this._super.apply(this, arguments).done(function() {
self.shortcut_check(self.views[view_type]);
});
},