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

bzr revid: fme@openerp.com-20121030140630-gf20ye8fou1ebxft
This commit is contained in:
Fabien Meghazi 2012-10-30 15:06:30 +01:00
parent eb1c4d0f93
commit ca6c49becf
23 changed files with 378 additions and 379 deletions

View File

@ -294,7 +294,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
start: function() {
var self = this;
$('.oe_secondary_menus_container,.oe_user_menu_placeholder').empty();
var fetch_db = this.rpc("/web/database/get_list", {}).pipe(
var fetch_db = this.rpc("/web/database/get_list", {}).then(
function(result) {
self.db_list = result.db_list;
},
@ -302,10 +302,10 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
ev.preventDefault();
self.db_list = null;
});
var fetch_langs = this.rpc("/web/session/get_lang_list", {}).then(function(result) {
var fetch_langs = this.rpc("/web/session/get_lang_list", {}).done(function(result) {
self.lang_list = result.lang_list;
});
return $.when(fetch_db, fetch_langs).then(self.do_render);
return $.when(fetch_db, fetch_langs).done(self.do_render);
},
do_render: function() {
var self = this;
@ -394,7 +394,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
do_create: function(form) {
var self = this;
var fields = $(form).serializeArray();
self.rpc("/web/database/create", {'fields': fields}).then(function(result) {
self.rpc("/web/database/create", {'fields': fields}).done(function(result) {
var form_obj = self.to_object(fields);
var client_action = {
type: 'ir.actions.client',
@ -420,7 +420,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) {
return;
}
self.rpc("/web/database/drop", {'fields': fields}).then(function(result) {
self.rpc("/web/database/drop", {'fields': fields}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
@ -483,7 +483,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
var self = this;
self.rpc("/web/database/change_password", {
'fields': $(form).serializeArray()
}).then(function(result) {
}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
@ -581,7 +581,7 @@ instance.web.Login = instance.web.Widget.extend({
var self = this;
self.hide_error();
self.$(".oe_login_pane").fadeOut("slow");
return this.session.session_authenticate(db, login, password).pipe(function() {
return this.session.session_authenticate(db, login, password).then(function() {
if (self.has_local_storage) {
if(self.remember_credentials) {
localStorage.setItem('last_db_login_success', db);
@ -663,7 +663,7 @@ instance.web.ChangePassword = instance.web.Widget.extend({
submitHandler: function (form) {
self.rpc("/web/session/change_password",{
'fields': $(form).serializeArray()
}).then(function(result) {
}).done(function(result) {
if (result.error) {
self.display_error(result);
return;
@ -702,7 +702,7 @@ instance.web.Menu = instance.web.Widget.extend({
},
do_reload: function() {
var self = this;
return this.rpc("/web/menu/load", {}).then(function(r) {
return this.rpc("/web/menu/load", {}).done(function(r) {
self.menu_loaded(r);
});
},
@ -872,7 +872,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
if (!self.session.uid)
return;
var func = new instance.web.Model("res.users").get_func("read");
return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
return func(self.session.uid, ["name", "company_id"]).then(function(res) {
var topbar_name = res.name;
if(instance.session.debug)
topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db);
@ -883,7 +883,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
$avatar.attr('src', avatar_src);
});
};
this.update_promise = this.update_promise.pipe(fct, fct);
this.update_promise = this.update_promise.then(fct, fct);
},
on_menu_logout: function() {
this.trigger('user_logout');
@ -899,7 +899,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
},
on_menu_about: function() {
var self = this;
self.rpc("/web/webclient/version_info", {}).then(function(res) {
self.rpc("/web/webclient/version_info", {}).done(function(res) {
var $help = $(QWeb.render("UserMenu.about", {version_info: res}));
$help.find('a.oe_activate_debug_mode').click(function (e) {
e.preventDefault();
@ -919,7 +919,7 @@ instance.web.Client = instance.web.Widget.extend({
},
start: function() {
var self = this;
return instance.session.session_bind(this.origin).pipe(function() {
return instance.session.session_bind(this.origin).then(function() {
var $e = $(QWeb.render(self._template, {}));
self.replaceElement($e);
self.bind_events();
@ -986,7 +986,7 @@ instance.web.WebClient = instance.web.Client.extend({
},
start: function() {
var self = this;
return $.when(this._super()).pipe(function() {
return $.when(this._super()).then(function() {
self.$el.on('click', '.oe_logo', function() {
self.action_manager.do_action('home');
});
@ -1055,8 +1055,8 @@ instance.web.WebClient = instance.web.Client.extend({
},
do_reload: function() {
var self = this;
return this.session.session_reload().pipe(function () {
instance.session.load_modules(true).pipe(
return this.session.session_reload().then(function () {
instance.session.load_modules(true).then(
self.menu.proxy('do_reload')); });
},
@ -1071,7 +1071,7 @@ instance.web.WebClient = instance.web.Client.extend({
on_logout: function() {
var self = this;
if (!this.has_uncommitted_changes()) {
this.session.session_logout().then(function () {
this.session.session_logout().done(function () {
$(window).unbind('hashchange', self.on_hashchange);
self.do_push_state({});
window.location.reload();
@ -1084,7 +1084,7 @@ instance.web.WebClient = instance.web.Client.extend({
var state = $.bbq.getState(true);
if (_.isEmpty(state) || state.action == "login") {
self.menu.has_been_loaded.then(function() {
self.menu.has_been_loaded.done(function() {
var first_menu_id = self.menu.$el.find("a:first").data("menu");
if(first_menu_id) {
self.menu.menu_click(first_menu_id);
@ -1099,8 +1099,8 @@ instance.web.WebClient = instance.web.Client.extend({
var state = event.getState(true);
if (!_.isEqual(this._current_state, state)) {
if(state.action_id === undefined && state.menu_id) {
self.menu.has_been_loaded.then(function() {
self.menu.do_reload().then(function() {
self.menu.has_been_loaded.done(function() {
self.menu.do_reload().done(function() {
self.menu.menu_click(state.menu_id)
});
});
@ -1121,7 +1121,7 @@ instance.web.WebClient = instance.web.Client.extend({
on_menu_action: function(options) {
var self = this;
return this.rpc("/web/action/load", { action_id: options.action_id })
.pipe(function (result) {
.then(function (result) {
var action = result;
if (options.needaction) {
action.context.search_default_message_unread = true;
@ -1167,9 +1167,9 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
},
start: function() {
var self = this;
return $.when(this._super()).pipe(function() {
return instance.session.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() {
return self.rpc("/web/action/load", { action_id: self.action_id }).then(function(result) {
return $.when(this._super()).then(function() {
return instance.session.session_authenticate(self.dbname, self.login, self.key, true).then(function() {
return self.rpc("/web/action/load", { action_id: self.action_id }).done(function(result) {
var action = result;
action.flags = _.extend({
//views_switcher : false,

View File

@ -811,10 +811,10 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, {
rpc: function(url, data, success, error) {
var def = $.Deferred().done(success).fail(error);
var self = this;
instance.session.rpc(url, data).then(function() {
instance.session.rpc(url, data).done(function() {
if (!self.isDestroyed())
def.resolve.apply(def, arguments);
}, function() {
}).fail(function() {
if (!self.isDestroyed())
def.reject.apply(def, arguments);
});
@ -1287,7 +1287,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
};
var deferred = $.Deferred();
this.trigger('request', url, payload);
var request = this.rpc_function(url, payload).then(
var request = this.rpc_function(url, payload).done(
function (response, textStatus, jqXHR) {
self.trigger('response', response);
if (!response.error) {
@ -1300,7 +1300,8 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
} else {
deferred.reject(response.error, $.Event());
}
},
}
).fail(
function(jqXHR, textStatus, errorThrown) {
self.trigger('response_failed', jqXHR);
var error = {
@ -1387,10 +1388,11 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({
$iframe.unbind('load').bind('load', function() {
$.ajax(ajax).always(function() {
cleanUp();
}).then(
function() { deferred.resolve.apply(deferred, arguments); },
function() { deferred.reject.apply(deferred, arguments); }
);
}).done(function() {
deferred.resolve.apply(deferred, arguments);
}).fail(function() {
deferred.reject.apply(deferred, arguments);
});
});
// now that the iframe can receive data, we fill and submit the form
$form.submit();

View File

@ -51,15 +51,15 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
var self = this;
// TODO: session store in cookie should be optional
this.session_id = this.get_cookie('session_id');
return this.session_reload().pipe(function(result) {
return this.session_reload().then(function(result) {
var modules = instance._modules.join(',');
var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).pipe(self.do_load_qweb);
var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).then(self.do_load_qweb);
if(self.session_is_valid()) {
return deferred.pipe(function() { return self.load_modules(); });
return deferred.then(function() { return self.load_modules(); });
}
return $.when(
deferred,
self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).pipe(function(trans) {
self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).then(function(trans) {
instance.web._t.database.set_bundle(trans);
})
);
@ -73,7 +73,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
*/
session_reload: function () {
var self = this;
return this.rpc("/web/session/get_session_info", {}).then(function(result) {
return this.rpc("/web/session/get_session_info", {}).done(function(result) {
// If immediately follows a login (triggered by trying to restore
// an invalid session or no session at all), refresh session data
// (should not change, but just in case...)
@ -96,7 +96,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
var self = this;
var base_location = document.location.protocol + '//' + document.location.host;
var params = { db: db, login: login, password: password, base_location: base_location };
return this.rpc("/web/session/authenticate", params).pipe(function(result) {
return this.rpc("/web/session/authenticate", params).then(function(result) {
if (!result.uid) {
return $.Deferred().reject();
}
@ -154,30 +154,30 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
*/
load_modules: function() {
var self = this;
return this.rpc('/web/session/modules', {}).pipe(function(result) {
return this.rpc('/web/session/modules', {}).then(function(result) {
var lang = self.user_context.lang,
all_modules = _.uniq(self.module_list.concat(result));
var params = { mods: all_modules, lang: lang};
var to_load = _.difference(result, self.module_list).join(',');
self.module_list = all_modules;
var loaded = self.rpc('/web/webclient/translations', params).then(function(trans) {
var loaded = self.rpc('/web/webclient/translations', params).done(function(trans) {
instance.web._t.database.set_bundle(trans);
});
var file_list = ["/web/static/lib/datejs/globalization/" + lang.replace("_", "-") + ".js"];
if(to_load.length) {
loaded = $.when(
loaded,
self.rpc('/web/webclient/csslist', {mods: to_load}).then(self.do_load_css),
self.rpc('/web/webclient/qweblist', {mods: to_load}).pipe(self.do_load_qweb),
self.rpc('/web/webclient/jslist', {mods: to_load}).then(function(files) {
self.rpc('/web/webclient/csslist', {mods: to_load}).done(self.do_load_css),
self.rpc('/web/webclient/qweblist', {mods: to_load}).then(self.do_load_qweb),
self.rpc('/web/webclient/jslist', {mods: to_load}).done(function(files) {
file_list = file_list.concat(files);
})
);
}
return loaded.pipe(function () {
return loaded.then(function () {
return self.do_load_js(file_list);
}).then(function() {
}).done(function() {
self.on_modules_loaded();
self.trigger('module_loaded');
if (!Date.CultureInfo.pmDesignator) {
@ -212,7 +212,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
if ( (tag.readyState && tag.readyState != "loaded" && tag.readyState != "complete") || tag.onload_done )
return;
tag.onload_done = true;
self.do_load_js(files).then(function () {
self.do_load_js(files).done(function () {
d.resolve();
});
};
@ -227,7 +227,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
var self = this;
_.each(files, function(file) {
self.qweb_mutex.exec(function() {
return self.rpc('/web/proxy/load', {path: file}).pipe(function(xml) {
return self.rpc('/web/proxy/load', {path: file}).then(function(xml) {
if (!xml) { return; }
instance.web.qweb.add_template(_.str.trim(xml));
});
@ -462,7 +462,7 @@ $.Mutex = (function() {
Mutex.prototype.exec = function(action) {
var current = this.def;
var next = this.def = $.Deferred();
return current.pipe(function() {
return current.then(function() {
return $.when(action()).always(function() {
next.resolve();
});
@ -474,7 +474,7 @@ $.Mutex = (function() {
$.async_when = function() {
var async = false;
var def = $.Deferred();
$.when.apply($, arguments).then(function() {
$.when.apply($, arguments).done(function() {
var args = arguments;
var action = function() {
def.resolve.apply(def, args);
@ -483,7 +483,7 @@ $.async_when = function() {
action();
else
setTimeout(action, 0);
}, function() {
}).fail(function() {
var args = arguments;
var action = function() {
def.reject.apply(def, args);

View File

@ -66,7 +66,7 @@ instance.web.Query = instance.web.Class.extend({
offset: this._offset,
limit: this._limit,
sort: instance.web.serialize_sort(this._order_by)
}).pipe(function (results) {
}).then(function (results) {
self._count = results.length;
return results.records;
}, null);
@ -78,7 +78,7 @@ instance.web.Query = instance.web.Class.extend({
*/
first: function () {
var self = this;
return this.clone({limit: 1})._execute().pipe(function (records) {
return this.clone({limit: 1})._execute().then(function (records) {
delete self._count;
if (records.length) { return records[0]; }
return null;
@ -132,7 +132,7 @@ instance.web.Query = instance.web.Class.extend({
offset: this._offset,
limit: this._limit,
orderby: instance.web.serialize_sort(this._order_by) || false
}).pipe(function (results) {
}).then(function (results) {
return _(results).map(function (result) {
// FIX: querygroup initialization
result.__context = result.__context || {};
@ -443,7 +443,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
return this._model.query(fields)
.limit(options.limit || false)
.offset(options.offset || 0)
.all().then(function (records) {
.all().done(function (records) {
self.ids = _(records).pluck('id');
});
},
@ -456,7 +456,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
*/
read_index: function (fields, options) {
options = options || {};
return this.read_ids([this.ids[this.index]], fields, options).pipe(function (records) {
return this.read_ids([this.ids[this.index]], fields, options).then(function (records) {
if (_.isEmpty(records)) { return $.Deferred().reject().promise(); }
return records[0];
});
@ -493,7 +493,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
*/
write: function (id, data, options) {
options = options || {};
return this._model.call('write', [[id], data], {context: this._model.context(options.context)}).then(this.trigger('dataset_changed', id, data, options));
return this._model.call('write', [[id], data], {context: this._model.context(options.context)}).done(this.trigger('dataset_changed', id, data, options));
},
/**
* Deletes an existing record from the database
@ -501,7 +501,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
* @param {Number|String} ids identifier of the record to delete
*/
unlink: function(ids) {
return this._model.call('unlink', [ids], {context: this._model.context()}).then(this.trigger('dataset_changed', ids));
return this._model.call('unlink', [ids], {context: this._model.context()}).done(this.trigger('dataset_changed', ids));
},
/**
* Calls an arbitrary RPC method
@ -607,7 +607,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
model: this.model,
ids: ids,
context: this._model.context(options.context),
}).pipe(function (results) {
}).then(function (results) {
return results;
});
},
@ -682,9 +682,9 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({
.limit(options.limit || false);
q = q.order_by.apply(q, this._sort);
return q.all().then(function (records) {
return q.all().done(function (records) {
// FIXME: not sure about that one, *could* have discarded count
q.count().then(function (count) { self._length = count; });
q.count().done(function (count) { self._length = count; });
self.ids = _(records).pluck('id');
});
},
@ -693,7 +693,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({
},
unlink: function(ids, callback, error_callback) {
var self = this;
return this._super(ids).then(function(result) {
return this._super(ids).done(function(result) {
self.ids = _(self.ids).difference(ids);
if (self._length) {
self._length -= 1;
@ -722,7 +722,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
this.last_default_get = {};
},
default_get: function(fields, options) {
return this._super(fields, options).then(this.on_default_get);
return this._super(fields, options).done(this.on_default_get);
},
on_default_get: function(res) {
this.last_default_get = res;
@ -774,7 +774,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
this.cache = _.reject(this.cache, function(x) { return _.include(ids, x.id);});
this.set_ids(_.without.apply(_, [this.ids].concat(ids)));
this.trigger("dataset_changed", ids, callback, error_callback);
return $.async_when({result: true}).then(callback);
return $.async_when({result: true}).done(callback);
},
reset_ids: function(ids) {
this.set_ids(ids);
@ -836,7 +836,7 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
completion.resolve(records);
};
if(to_get.length > 0) {
var rpc_promise = this._super(to_get, fields, options).then(function(records) {
var rpc_promise = this._super(to_get, fields, options).done(function(records) {
_.each(records, function(record, index) {
var id = to_get[index];
var cached = _.detect(self.cache, function(x) {return x.id === id;});
@ -991,14 +991,14 @@ instance.web.DropMisordered = instance.web.Class.extend({
var res = $.Deferred();
var self = this, seq = this.lsn++;
deferred.then(function () {
deferred.done(function () {
if (seq > self.rsn) {
self.rsn = seq;
res.resolve.apply(res, arguments);
} else if (self.failMisordered) {
res.reject();
}
}, function () {
}).fail(function () {
res.reject.apply(res, arguments);
});

View File

@ -51,7 +51,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
self.rpc("/web/export/get_fields", {
model: self.dataset.model,
import_compat: Boolean(import_comp)
}).then(function (records) {
}).done(function (records) {
got_fields.resolve();
self.on_show_data(records);
});
@ -59,7 +59,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
return $.when(
got_fields,
this.rpc('/web/export/formats', {}).then(this.do_setup_export_formats),
this.rpc('/web/export/formats', {}).done(this.do_setup_export_formats),
this.show_exports_list());
},
do_setup_export_formats: function (formats) {
@ -84,7 +84,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
}
return this.exports.read_slice(['name'], {
domain: [['resource', '=', this.dataset.model]]
}).then(function (export_list) {
}).done(function (export_list) {
if (!export_list.length) {
return;
}
@ -93,7 +93,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
self.$el.find('#fields_list option').remove();
var export_id = self.$el.find('#saved_export_list option:selected').val();
if (export_id) {
self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}).then(self.do_load_export_field);
self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}).done(self.do_load_export_field);
}
});
self.$el.find('#delete_export_list').click(function() {
@ -183,7 +183,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
import_compat: Boolean(import_comp),
parent_field_type : record['field_type'],
exclude: exclude_fields
}).then(function(results) {
}).done(function(results) {
record.loaded = true;
self.on_show_data(results, record.id);
});

View File

@ -244,7 +244,7 @@ my.FacetView = instance.web.Widget.extend({
});
var $e = self.$el.find('> span:last-child');
var q = $.when(this._super());
return q.pipe(function () {
return q.then(function () {
var values = self.model.values.map(function (value) {
return new my.FacetValueView(self, value).appendTo($e);
});
@ -324,7 +324,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
context: this.dataset.get_context() });
$.when(load_view)
.pipe(function(r) {
.then(function(r) {
self.search_view_loaded(r)
}).fail(function () {
self.ready.reject.apply(null, arguments);
@ -492,7 +492,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
complete_global_search: function (req, resp) {
$.when.apply(null, _(this.inputs).chain()
.invoke('complete', req.term)
.value()).then(function () {
.value()).done(function () {
resp(_(_(arguments).compact()).flatten(true));
});
},
@ -560,7 +560,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
childView.on('blurred', self, self.proxy('childBlurred'));
});
$.when.apply(null, started).then(function () {
$.when.apply(null, started).done(function () {
var input_to_focus;
// options.at: facet inserted at given index, focus next input
// otherwise just focus last input
@ -668,12 +668,12 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
// load defaults
var defaults_fetched = $.when.apply(null, _(this.inputs).invoke(
'facet_for_defaults', this.defaults)).then(function () {
'facet_for_defaults', this.defaults)).done(function () {
self.query.reset(_(arguments).compact(), {preventSearch: true});
});
return $.when(drawer_started, defaults_fetched)
.then(function () {
.done(function () {
self.trigger("search_view_loaded", data);
self.ready.resolve();
});
@ -1439,7 +1439,7 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
name: needle,
limit: 8,
context: {}
}).pipe(function (results) {
}).then(function (results) {
if (_.isEmpty(results)) { return null; }
return [{label: self.attrs.string}].concat(
_(results).map(function (result) {
@ -1462,7 +1462,7 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
// to handle this as if it were a single value.
value = value[0];
}
return this.model.call('name_get', [value]).pipe(function (names) {
return this.model.call('name_get', [value]).then(function (names) {
if (_(names).isEmpty()) { return null; }
return facet_from(self, names[0]);
})
@ -1509,7 +1509,7 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
// FIXME: local eval of domain and context to get rid of special endpoint
return this.rpc('/web/searchview/get_filters', {
model: this.view.model
}).pipe(this.proxy('set_filters'));
}).then(this.proxy('set_filters'));
},
clear_selection: function () {
this.$el.find('li.oe_selected').removeClass('oe_selected');
@ -1532,7 +1532,7 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
$('<a class="oe_searchview_custom_delete">x</a>')
.click(function (e) {
e.stopPropagation();
self.model.call('unlink', [id]).then(function () {
self.model.call('unlink', [id]).done(function () {
$filter.remove();
});
})
@ -1567,7 +1567,7 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
domains: search.domains,
contexts: search.contexts,
group_by_seq: search.groupbys || []
}).then(function (results) {
}).done(function (results) {
if (!_.isEmpty(results.group_by)) {
results.context.group_by = results.group_by;
}
@ -1579,7 +1579,7 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
domain: results.domain
};
// FIXME: current context?
return self.model.call('create_or_replace', [filter]).then(function (id) {
return self.model.call('create_or_replace', [filter]).done(function (id) {
filter.id = id;
self.append_filter(filter);
self.$el
@ -1656,11 +1656,11 @@ instance.web.search.Advanced = instance.web.search.Input.extend({
});
return $.when(
this._super(),
this.rpc("/web/searchview/fields_get", {model: this.view.model}).then(function(data) {
this.rpc("/web/searchview/fields_get", {model: this.view.model}).done(function(data) {
self.fields = _.extend({
id: { string: 'ID', type: 'id' }
}, data.fields);
})).then(function () {
})).done(function () {
self.append_proposition();
});
},

View File

@ -32,20 +32,20 @@ openerp.test_support = {
window.openerp.web[tested_core](oe);
var done = openerp.test_support.setup_session(oe.session);
if (nonliterals) {
done = done.pipe(function () {
done = done.then(function () {
return oe.session.rpc('/tests/add_nonliterals', {
domains: nonliterals.domains || [],
contexts: nonliterals.contexts || []
}).then(function (r) {
}).done(function (r) {
oe.domains = r.domains;
oe.contexts = r.contexts;
});
});
}
done.always(QUnit.start)
.then(function () {
.done(function () {
conf.openerp = oe;
}, function (e) {
}).fail(function (e) {
QUnit.test(title, function () {
console.error(e);
QUnit.ok(false, 'Could not obtain a session:' + e.debug);

View File

@ -120,7 +120,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.__blur_timeout = null;
this.rendering_engine = new instance.web.form.FormRenderingEngine(this);
self.set({actual_mode: self.options.initial_mode});
this.has_been_loaded.then(function() {
this.has_been_loaded.done(function() {
self.on("change:actual_mode", self, self.check_actual_mode);
self.check_actual_mode();
self.on("change:actual_mode", self, self.init_pager);
@ -274,7 +274,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var shown = this.has_been_loaded;
if (options.reload !== false) {
shown = shown.pipe(function() {
shown = shown.then(function() {
if (self.dataset.index === null) {
// null index means we should start a new record
return self.on_button_new();
@ -283,12 +283,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
fields.push('display_name');
return self.dataset.read_index(fields, {
context: { 'bin_size': true, 'future_display_name' : true }
}).pipe(function(r) {
}).then(function(r) {
self.trigger('load_record', r);
});
});
}
return shown.pipe(function() {
return shown.then(function() {
self._actualize_mode(options.mode || self.options.initial_mode);
self.$el.css({
opacity: '1',
@ -326,7 +326,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
field._inhibit_on_change_flag = false;
set_values.push(result);
});
return $.when.apply(null, set_values).pipe(function() {
return $.when.apply(null, set_values).then(function() {
if (!record.id) {
// New record: Second pass in order to trigger the onchanges
// respecting the fields order defined in the view
@ -364,7 +364,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var self = this;
var keys = _.keys(this.fields_view.fields);
if (keys.length) {
return this.dataset.default_get(keys).pipe(function(r) {
return this.dataset.default_get(keys).then(function(r) {
self.trigger('load_record', r);
});
}
@ -510,7 +510,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
method: change_spec.method,
args: [(self.datarecord.id == null ? [] : [self.datarecord.id])].concat(change_spec.args),
context_id: change_spec.context_index == undefined ? null : change_spec.context_index + 1
}).then(function(r) {
}).done(function(r) {
_.extend(response, r);
});
} else {
@ -518,7 +518,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}
}
// fail if onchange failed
if (can_process_onchange.isRejected()) {
if (can_process_onchange.state() === 'rejected') {
return can_process_onchange;
}
@ -541,7 +541,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
model: 'ir.values',
method: 'get_defaults',
args: [self.model, condition]
}).then(function (results) {
}).done(function (results) {
if (!results.length) { return; }
if (!response.value) {
response.value = {};
@ -554,7 +554,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
});
}
}
if (can_process_onchange.isRejected()) {
if (can_process_onchange.state() === 'rejected') {
return can_process_onchange;
}
@ -693,7 +693,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
},
on_button_save: function() {
var self = this;
return this.save().then(function(result) {
return this.save().done(function(result) {
self.trigger("save", result);
self.to_view_mode();
});
@ -713,7 +713,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
on_button_new: function() {
var self = this;
this.to_edit_mode();
return $.when(this.has_been_loaded).pipe(function() {
return $.when(this.has_been_loaded).then(function() {
if (self.can_be_discarded()) {
return self.load_defaults();
}
@ -728,29 +728,24 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
},
on_button_duplicate: function() {
var self = this;
var def = $.Deferred();
$.when(this.has_been_loaded).then(function() {
self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
return self.record_created(new_id);
}).then(function() {
return self.to_edit_mode();
}).then(function() {
def.resolve();
return this.has_been_loaded.then(function() {
return self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
self.record_created(new_id);
self.to_edit_mode();
});
});
return def.promise();
},
on_button_delete: function() {
var self = this;
var def = $.Deferred();
$.when(this.has_been_loaded).then(function() {
this.has_been_loaded.done(function() {
if (self.datarecord.id && confirm(_t("Do you really want to delete this record?"))) {
self.dataset.unlink([self.datarecord.id]).then(function() {
self.dataset.unlink([self.datarecord.id]).done(function() {
self.execute_pager_action('next');
def.resolve();
});
} else {
$.async_when().then(function () {
$.async_when().done(function () {
def.reject();
})
}
@ -777,7 +772,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
*/
save: function(prepend_on_create) {
var self = this;
return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() {
return this.mutating_mutex.exec(function() { return self.is_initialized.then(function() {
try {
var form_invalid = false,
values = {},
@ -807,7 +802,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var save_deferral;
if (!self.datarecord.id) {
// Creation save
save_deferral = self.dataset.create(values).pipe(function(r) {
save_deferral = self.dataset.create(values).then(function(r) {
return self.record_created(r, prepend_on_create);
}, null);
} else if (_.isEmpty(values) && ! self.force_dirty) {
@ -816,7 +811,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
} else {
self.force_dirty = false;
// Write save
save_deferral = self.dataset.write(self.datarecord.id, values, {}).pipe(function(r) {
save_deferral = self.dataset.write(self.datarecord.id, values, {}).then(function(r) {
return self.record_saved(r);
}, null);
}
@ -851,7 +846,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.trigger('record_saved', r);
return $.Deferred().reject();
} else {
return $.when(this.reload()).pipe(function () {
return $.when(this.reload()).then(function () {
self.trigger('record_saved', r);
return r;
});
@ -890,7 +885,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.sidebar.do_attachement_update(this.dataset, this.datarecord.id);
}
//openerp.log("The record has been created with id #" + this.datarecord.id);
return $.when(this.reload()).pipe(function () {
return $.when(this.reload()).then(function () {
self.trigger('record_created', r);
return _.extend(r, {created: true});
});
@ -917,7 +912,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
'bin_size': true,
'future_display_name': true
}
}).pipe(function(r) {
}).then(function(r) {
self.trigger('load_record', r);
});
}
@ -947,7 +942,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
},
recursive_save: function() {
var self = this;
return $.when(this.save()).pipe(function(res) {
return $.when(this.save()).then(function(res) {
if (self.dataset.parent_view)
return self.dataset.parent_view.recursive_save();
});
@ -957,7 +952,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var pre = $.when();
if (self.dataset.parent_view)
pre = self.dataset.parent_view.recursive_reload();
return pre.pipe(function() {
return pre.then(function() {
return self.reload();
});
},
@ -978,7 +973,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
return true;
},
sidebar_context: function () {
return this.save().pipe(_.bind(function() {return this.get_fields_values();}, this));
return this.save().then(_.bind(function() {return this.get_fields_values();}, this));
},
open_defaults_dialog: function () {
var self = this;
@ -1054,7 +1049,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
all_users,
true,
condition || false
]).then(function () { d.close(); });
]).done(function () { d.close(); });
}}
]
});
@ -1883,7 +1878,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
}
},
{text: _t("Ok"), click: function() {
self.on_confirmed().then(function() {
self.on_confirmed().done(function() {
def.resolve();
});
$(this).dialog("close");
@ -1898,7 +1893,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
};
if (!this.node.attrs.special) {
this.view.force_dirty = true;
return this.view.recursive_save().pipe(exec_action);
return this.view.recursive_save().then(exec_action);
} else {
return exec_action();
}
@ -2117,7 +2112,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
on_translate: function() {
var self = this;
var trans = new instance.web.DataSet(this, 'ir.translation');
return trans.call_button('translate_fields', [this.view.dataset.model, this.view.datarecord.id, this.name, this.view.dataset.get_context()]).then(function(r) {
return trans.call_button('translate_fields', [this.view.dataset.model, this.view.datarecord.id, this.name, this.view.dataset.get_context()]).done(function(r) {
self.do_action(r);
});
},
@ -2732,7 +2727,7 @@ instance.web.form.CompletionFieldMixin = {
return this.orderer.add(dataset.name_search(
search_val, new instance.web.CompoundDomain(self.build_domain(), [["id", "not in", blacklist]]),
'ilike', this.limit + 1, self.build_context())).pipe(function(data) {
'ilike', this.limit + 1, self.build_context())).then(function(data) {
self.last_search = data;
// possible selections for the m2o
var values = _.map(data, function(x) {
@ -2751,7 +2746,7 @@ instance.web.form.CompletionFieldMixin = {
values.push({
label: _t("Search More..."),
action: function() {
dataset.name_search(search_val, self.build_domain(), 'ilike', false).then(function(data) {
dataset.name_search(search_val, self.build_domain(), 'ilike', false).done(function(data) {
self._search_create_popup("search", data);
});
},
@ -2792,7 +2787,7 @@ instance.web.form.CompletionFieldMixin = {
};
if (self.options.quick_create === undefined || self.options.quick_create) {
new instance.web.DataSet(this, this.field.relation, self.build_context())
.name_create(name).then(function(data) {
.name_create(name).done(function(data) {
self.add_id(data[0]);
}).fail(function(error, event) {
event.preventDefault();
@ -2989,14 +2984,14 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
self.ed_def.reject();
self.uned_def.reject();
self.ed_def = $.Deferred();
self.ed_def.then(function() {
self.ed_def.done(function() {
self.show_error_displayer();
});
setTimeout(function() {
self.ed_def.resolve();
self.uned_def.reject();
self.uned_def = $.Deferred();
self.uned_def.then(function() {
self.uned_def.done(function() {
self.hide_error_displayer();
});
setTimeout(function() {self.uned_def.resolve();}, ed_duration);
@ -3026,7 +3021,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
// autocomplete
this.$input.autocomplete({
source: function(req, resp) {
self.get_search_result(req.term).then(function(result) {
self.get_search_result(req.term).done(function(result) {
resp(result);
});
},
@ -3077,7 +3072,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
}
if (! no_recurse) {
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
dataset.name_get([self.get("value")]).then(function(data) {
dataset.name_get([self.get("value")]).done(function(data) {
self.display_value["" + self.get("value")] = data[0][1];
self.render_value(true);
});
@ -3230,11 +3225,11 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
var self = this;
self.load_views();
this.is_loaded.then(function() {
this.is_loaded.done(function() {
self.on("change:effective_readonly", self, function() {
self.is_loaded = self.is_loaded.pipe(function() {
self.is_loaded = self.is_loaded.then(function() {
self.viewmanager.destroy();
return $.when(self.load_views()).then(function() {
return $.when(self.load_views()).done(function() {
self.reload_current_view();
});
});
@ -3307,10 +3302,10 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
this.viewmanager = new instance.web.form.One2ManyViewManager(this, this.dataset, views, {});
this.viewmanager.o2m = self;
var once = $.Deferred().then(function() {
var once = $.Deferred().done(function() {
self.init_form_last_update.resolve();
});
var def = $.Deferred().then(function() {
var def = $.Deferred().done(function() {
self.initial_is_loaded.resolve();
});
this.viewmanager.on("controller_inited", self, function(view_type, controller) {
@ -3342,22 +3337,22 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
def.resolve();
});
this.viewmanager.on("switch_mode", self, function(n_mode, b, c, d, e) {
$.when(self.save_any_view()).then(function() {
$.when(self.save_any_view()).done(function() {
if (n_mode === "list") {
$.async_when().then(function() {
$.async_when().done(function() {
self.reload_current_view();
});
}
});
});
$.async_when().then(function () {
$.async_when().done(function () {
self.viewmanager.appendTo(self.$el);
});
return def;
},
reload_current_view: function() {
var self = this;
return self.is_loaded = self.is_loaded.pipe(function() {
return self.is_loaded = self.is_loaded.then(function() {
var active_view = self.viewmanager.active_view;
var view = self.viewmanager.views[active_view].controller;
if(active_view === "list") {
@ -3369,7 +3364,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
var act = function() {
return view.do_show();
};
self.form_last_update = self.form_last_update.pipe(act, act);
self.form_last_update = self.form_last_update.then(act, act);
return self.form_last_update;
} else if (view.do_search) {
return view.do_search(self.build_domain(), self.dataset.get_context(), []);
@ -3468,17 +3463,17 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
this.viewmanager.views[this.viewmanager.active_view].controller) {
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
if (this.viewmanager.active_view === "form") {
if (!view.is_initialized.isResolved()) {
if (!view.is_initialized.state() === 'resolved') {
return false;
}
var res = $.when(view.save());
if (!res.isResolved() && !res.isRejected()) {
if (res.state() === 'pending') {
console.warn("Asynchronous get_value() is not supported in form view.");
}
return res;
} else if (this.viewmanager.active_view === "list") {
var res = $.when(view.ensure_saved());
if (!res.isResolved() && !res.isRejected()) {
if (res.state() === 'pending') {
console.warn("Asynchronous get_value() is not supported in list view.");
}
return res;
@ -3526,13 +3521,13 @@ instance.web.form.One2ManyViewManager = instance.web.ViewManager.extend({
pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), {
title: _t("Open: ") + self.o2m.string,
create_function: function(data) {
return self.o2m.dataset.create(data).then(function(r) {
return self.o2m.dataset.create(data).done(function(r) {
self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r]));
self.o2m.dataset.trigger("dataset_changed", r);
});
},
write_function: function(id, data, options) {
return self.o2m.dataset.write(id, data, {}).then(function() {
return self.o2m.dataset.write(id, data, {}).done(function() {
self.o2m.reload_current_view();
});
},
@ -3617,10 +3612,10 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
initial_view: "form",
alternative_form_view: self.o2m.field.views ? self.o2m.field.views["form"] : undefined,
create_function: function(data, callback, error_callback) {
return self.o2m.dataset.create(data).then(function(r) {
return self.o2m.dataset.create(data).done(function(r) {
self.o2m.dataset.set_ids(self.o2m.dataset.ids.concat([r]));
self.o2m.dataset.trigger("dataset_changed", r);
}).then(callback, error_callback);
}).done(callback).fail(error_callback);
},
read_function: function() {
return self.o2m.dataset.read_ids.apply(self.o2m.dataset, arguments);
@ -3643,7 +3638,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
pop.show_element(self.o2m.field.relation, id, self.o2m.build_context(), {
title: _t("Open: ") + self.o2m.string,
write_function: function(id, data) {
return self.o2m.dataset.write(id, data, {}).then(function() {
return self.o2m.dataset.write(id, data, {}).done(function() {
self.o2m.reload_current_view();
});
},
@ -3666,12 +3661,12 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
}
var parent_form = this.o2m.view;
var self = this;
this.ensure_saved().pipe(function () {
this.ensure_saved().then(function () {
if (parent_form)
return parent_form.save();
else
return $.when();
}).then(function () {
}).done(function () {
self.handle_button(name, id, callback);
});
},
@ -3731,7 +3726,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
ids.splice(false_id_index, 1);
next = this.cancel_edition(true);
}
return next.pipe(function () {
return next.then(function () {
// wheeee
var confirm = window.confirm;
window.confirm = function () { return true; };
@ -3793,7 +3788,7 @@ instance.web.form.One2ManyList = instance.web.ListView.List.extend({
clearTimeout(self.view.editor.form.__blur_timeout);
self.view.editor.form.__blur_timeout = false;
}
self.view.ensure_saved().then(function () {
self.view.ensure_saved().done(function () {
self.view.do_add_record();
});
}));
@ -3814,7 +3809,7 @@ instance.web.form.One2ManyFormView = instance.web.FormView.extend({
this._super(data);
var self = this;
this.$buttons.find('button.oe_form_button_create').click(function() {
self.save().then(self.on_button_new);
self.save().done(self.on_button_new);
});
},
do_notify_change: function() {
@ -3892,7 +3887,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in
}).bind('getSuggestions', function(e, data) {
var _this = this;
var str = !!data ? data.query || '' : '';
self.get_search_result(str).then(function(result) {
self.get_search_result(str).done(function(result) {
self.search_result = result;
$(_this).trigger('setSuggestions', {result : _.map(result, function(el, i) {
return _.extend(el, {index:i});
@ -3945,7 +3940,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in
}
};
if (! values || values.length > 0) {
this._display_orderer.add(dataset.name_get(values)).then(handle_names);
this._display_orderer.add(dataset.name_get(values)).done(handle_names);
} else {
handle_names([]);
}
@ -3982,11 +3977,11 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({
var self = this;
self.load_view();
this.is_loaded.then(function() {
this.is_loaded.done(function() {
self.on("change:effective_readonly", self, function() {
self.is_loaded = self.is_loaded.pipe(function() {
self.is_loaded = self.is_loaded.then(function() {
self.list_view.destroy();
return $.when(self.load_view()).then(function() {
return $.when(self.load_view()).done(function() {
self.render_value();
});
});
@ -4027,7 +4022,7 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({
self.initial_is_loaded.resolve();
loaded.resolve();
});
$.async_when().then(function () {
$.async_when().done(function () {
self.list_view.appendTo(self.$el);
});
return loaded;
@ -4035,7 +4030,7 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({
render_value: function() {
var self = this;
this.dataset.set_ids(this.get("value"));
this.is_loaded = this.is_loaded.pipe(function() {
this.is_loaded = this.is_loaded.then(function() {
return self.list_view.reload_content();
});
},
@ -4096,7 +4091,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in
if (! this.m2m_field.options.reload_on_button) {
return _sup(name, id, callback);
} else {
return this.m2m_field.view.save().pipe(function() {
return this.m2m_field.view.save().then(function() {
return _sup(name, id, function() {
self.m2m_field.view.reload();
});
@ -4127,11 +4122,11 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
var self = this;
self.load_view();
this.is_loaded.then(function() {
this.is_loaded.done(function() {
self.on("change:effective_readonly", self, function() {
self.is_loaded = self.is_loaded.pipe(function() {
self.is_loaded = self.is_loaded.then(function() {
self.kanban_view.destroy();
return $.when(self.load_view()).then(function() {
return $.when(self.load_view()).done(function() {
self.render_value();
});
});
@ -4168,7 +4163,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
loaded.resolve();
});
this.kanban_view.on('switch_mode', this, this.open_popup);
$.async_when().then(function () {
$.async_when().done(function () {
self.kanban_view.appendTo(self.$el);
});
return loaded;
@ -4176,7 +4171,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
render_value: function() {
var self = this;
this.dataset.set_ids(this.get("value"));
this.is_loaded = this.is_loaded.pipe(function() {
this.is_loaded = this.is_loaded.then(function() {
return self.kanban_view.do_search(self.build_domain(), self.dataset.get_context(), []);
});
},
@ -4212,7 +4207,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
pop.show_element(self.field.relation, id, self.build_context(), {
title: _t("Open: ") + self.string,
write_function: function(id, data, options) {
return self.dataset.write(id, data, {}).then(function() {
return self.dataset.write(id, data, {}).done(function() {
self.render_value();
});
},
@ -4285,7 +4280,7 @@ instance.web.form.Many2ManyQuickCreate = instance.web.Widget.extend({
}).bind('getSuggestions', function(e, data) {
var _this = this;
var str = !!data ? data.query || '' : '';
self.m2m.get_search_result(str).then(function(result) {
self.m2m.get_search_result(str).done(function(result) {
self.search_result = result;
$(_this).trigger('setSuggestions', {result : _.map(result, function(el, i) {
return _.extend(el, {index:i});
@ -4340,13 +4335,13 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
this.dataset.read_function = this.options.read_function;
this.dataset.create_function = function(data, sup) {
var fct = self.options.create_function || sup;
return fct.call(this, data).then(function(r) {
return fct.call(this, data).done(function(r) {
self.created_elements.push(r);
});
};
this.dataset.write_function = function(id, data, options, sup) {
var fct = self.options.write_function || sup;
return fct.call(this, id, data, options).then(function() {
return fct.call(this, id, data, options).done(function() {
self.trigger('write_completed');
});
};
@ -4395,7 +4390,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
}));
var $snbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save-new");
$snbutton.click(function() {
$.when(self.view_form.save()).then(function() {
$.when(self.view_form.save()).done(function() {
self.view_form.reload_mutex.exec(function() {
self.view_form.on_button_new();
});
@ -4403,7 +4398,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({
});
var $sbutton = self.$buttonpane.find(".oe_abstractformpopup-form-save");
$sbutton.click(function() {
$.when(self.view_form.save()).then(function() {
$.when(self.view_form.save()).done(function() {
self.view_form.reload_mutex.exec(function() {
self.check_exit();
});
@ -4477,7 +4472,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
self.rpc('/web/session/eval_domain_and_context', {
domains: [],
contexts: [this.context]
}).then(function (results) {
}).done(function (results) {
var search_defaults = {};
_.each(results.context, function (value_, key) {
var match = /^search_default_(.*)$/.exec(key);
@ -4519,9 +4514,9 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
e.cancel = true;
});
self.view_list.popup = self;
self.view_list.appendTo($(".oe_popup_list", self.$el)).pipe(function() {
self.view_list.appendTo($(".oe_popup_list", self.$el)).then(function() {
self.view_list.do_show();
}).pipe(function() {
}).then(function() {
self.searchview.do_search();
});
self.view_list.on("list_view_loaded", self, function() {
@ -4549,7 +4544,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
domains: domains || [],
contexts: contexts || [],
group_by_seq: groupbys || []
}).then(function (results) {
}).done(function (results) {
self.view_list.do_search(results.domain, results.context, results.group_by);
});
},
@ -4899,7 +4894,7 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
},
render_value: function() {
var self = this;
self.get_selection().then(function() {
self.get_selection().done(function() {
var content = QWeb.render("FieldStatus.content", {widget: self});
self.$el.html(content);
var colors = JSON.parse((self.node.attrs || {}).statusbar_colors || "{}");
@ -4923,7 +4918,7 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
domain = new instance.web.CompoundDomain(['|'], self.build_domain(), [['id', '=', self.get('value')]]);
}
var ds = new instance.web.DataSetSearch(this, this.field.relation, self.build_context(), domain);
return ds.read_slice(['name'], {}).pipe(function (records) {
return ds.read_slice(['name'], {}).then(function (records) {
for(var i = 0; i < records.length; i++) {
self.selection.push([records[i].id, records[i].name]);
}
@ -4947,10 +4942,10 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
var $li = $(ev.currentTarget);
var val = parseInt($li.data("id"));
if (val != self.get('value')) {
this.view.recursive_save().then(function() {
this.view.recursive_save().done(function() {
var change = {};
change[self.name] = val;
self.view.dataset.write(self.view.datarecord.id, change).then(function() {
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
self.view.reload();
});
});
@ -4984,7 +4979,7 @@ instance.web.form.FieldMonetary = instance.web.form.FieldFloat.extend({
return;
}
return this.ci_dm.add(new instance.web.Model("res.currency").query(["symbol", "position"])
.filter([["id", "=", self.get("currency")]]).first()).pipe(function(res) {
.filter([["id", "=", self.get("currency")]]).first()).then(function(res) {
self.set({"currency_info": res});
});
},

View File

@ -508,7 +508,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
_.pluck(_(this.columns).filter(function (r) {
return r.tag === 'field';
}), 'name')
).then(function (records) {
).done(function (records) {
_(records[0]).each(function (value, key) {
record.set(key, value, {silent: true});
});
@ -553,7 +553,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
this.no_leaf = !!context['group_by_no_leaf'];
this.grouped = !!group_by;
return this.load_view(context).pipe(
return this.load_view(context).then(
this.proxy('reload_content'));
},
/**
@ -566,7 +566,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
return;
}
var self = this;
return $.when(this.dataset.unlink(ids)).then(function () {
return $.when(this.dataset.unlink(ids)).done(function () {
_(ids).each(function (id) {
self.records.remove(self.records.get(id));
});
@ -976,7 +976,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
// to get a correctly displayable value in the field
var model = ref_match[1],
id = parseInt(ref_match[2], 10);
new instance.web.DataSet(this.view, model).name_get([id]).then(function(names) {
new instance.web.DataSet(this.view, model).name_get([id]).done(function(names) {
if (!names.length) { return; }
record.set(column.id, names[0][1]);
});
@ -992,7 +992,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
// and let the various registered events handle refreshing the
// row
new instance.web.DataSet(this.view, column.relation)
.name_get([value]).then(function (names) {
.name_get([value]).done(function (names) {
if (!names.length) { return; }
record.set(column.id, names[0]);
});
@ -1015,7 +1015,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
ids = value;
}
new instance.web.Model(column.relation)
.call('name_get', [ids]).then(function (names) {
.call('name_get', [ids]).done(function (names) {
record.set(column.id, _(names).pluck(1).join(', '));
})
}
@ -1384,43 +1384,45 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
var fields = _.pluck(_.select(this.columns, function(x) {return x.tag == "field"}), 'name');
var options = { offset: page * limit, limit: limit, context: {bin_size: true} };
//TODO xmo: investigate why we need to put the setTimeout
$.async_when().then(function() {dataset.read_slice(fields, options).then(function (records) {
// FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently
if (self.records.length) {
self.records.reset(null, {silent: true});
}
if (!self.datagroup.openable) {
view.configure_pager(dataset);
} else {
if (dataset.size() == records.length) {
// only one page
self.$row.find('td.oe_list_group_pagination').empty();
} else {
var pages = Math.ceil(dataset.size() / limit);
self.$row
.find('.oe_list_pager_state')
.text(_.str.sprintf(_t("%(page)d/%(page_count)d"), {
page: page + 1,
page_count: pages
}))
.end()
.find('button[data-pager-action=previous]')
.css('visibility',
page === 0 ? 'hidden' : '')
.end()
.find('button[data-pager-action=next]')
.css('visibility',
page === pages - 1 ? 'hidden' : '');
$.async_when().done(function() {
dataset.read_slice(fields, options).done(function (records) {
// FIXME: ignominious hacks, parents (aka form view) should not send two ListView#reload_content concurrently
if (self.records.length) {
self.records.reset(null, {silent: true});
}
if (!self.datagroup.openable) {
view.configure_pager(dataset);
} else {
if (dataset.size() == records.length) {
// only one page
self.$row.find('td.oe_list_group_pagination').empty();
} else {
var pages = Math.ceil(dataset.size() / limit);
self.$row
.find('.oe_list_pager_state')
.text(_.str.sprintf(_t("%(page)d/%(page_count)d"), {
page: page + 1,
page_count: pages
}))
.end()
.find('button[data-pager-action=previous]')
.css('visibility',
page === 0 ? 'hidden' : '')
.end()
.find('button[data-pager-action=next]')
.css('visibility',
page === pages - 1 ? 'hidden' : '');
}
}
}
self.records.add(records, {silent: true});
list.render();
d.resolve(list);
if (_.isEmpty(records)) {
view.no_result();
}
});});
self.records.add(records, {silent: true});
list.render();
d.resolve(list);
if (_.isEmpty(records)) {
view.no_result();
}
});
});
return d.promise();
},
setup_resequence_rows: function (list, dataset) {
@ -1476,7 +1478,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
// Accounting > Taxes > Taxes, child tax accounts)
// when synchronous (without setTimeout)
(function (dataset, id, seq) {
$.async_when().then(function () {
$.async_when().done(function () {
var attrs = {};
attrs[seqname] = seq;
dataset.write(id, attrs);
@ -1501,7 +1503,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
self.render_groups(groups));
if (post_render) { post_render(); }
}, function (dataset) {
self.render_dataset(dataset).then(function (list) {
self.render_dataset(dataset).done(function (list) {
self.children[null] = list;
self.elements =
[list.$current.replaceAll($el)[0]];
@ -1561,7 +1563,7 @@ var DataGroup = instance.web.CallbackEnabled.extend({
list: function (fields, ifGroups, ifRecords) {
var self = this;
var query = this.model.query(fields).order_by(this.sort).group_by(this.group_by);
$.when(query).then(function (querygroups) {
$.when(query).done(function (querygroups) {
// leaf node
if (!querygroups) {
var ds = new instance.web.DataSetSearch(self, self.model.name, self.model.context(), self.model.domain());

View File

@ -127,7 +127,7 @@ openerp.web.list_editable = function (instance) {
// restartable
this.editor = this.make_editor();
var editor_ready = this.editor.prependTo(this.$el)
.then(this.proxy('setup_events'));
.done(this.proxy('setup_events'));
return $.when(result, editor_ready);
} else {
@ -146,7 +146,7 @@ openerp.web.list_editable = function (instance) {
},
do_button_action: function (name, id, callback) {
var self = this, args = arguments;
this.ensure_saved().then(function (done) {
this.ensure_saved().done(function (done) {
if (!id && done.created) {
id = done.record.get('id');
}
@ -191,7 +191,7 @@ openerp.web.list_editable = function (instance) {
at: this.prepends_on_create() ? 0 : null});
}
return this.ensure_saved().pipe(function () {
return this.ensure_saved().then(function () {
var $recordRow = self.groups.get_row_for(record);
var cells = self.get_cells_for($recordRow);
self.fields_for_resize.splice(0, self.fields_for_resize.length);
@ -208,7 +208,7 @@ openerp.web.list_editable = function (instance) {
// FIXME: need better way to get the field back from bubbling (delegated) DOM events somehow
field.$el.attr('data-fieldname', field_name);
self.fields_for_resize.push({field: field, cell: cell});
}, options).pipe(function () {
}, options).then(function () {
$recordRow.addClass('oe_edition');
self.resize_fields();
return record.attributes;
@ -267,7 +267,7 @@ openerp.web.list_editable = function (instance) {
form: this.editor.form,
cancel: false
}, function () {
return this.editor.save().pipe(function (attrs) {
return this.editor.save().then(function (attrs) {
var created = false;
var record = self.records.get(attrs.id);
if (!record) {
@ -281,9 +281,9 @@ openerp.web.list_editable = function (instance) {
// record which has *just* been saved, so first perform all
// onwrites then do a final reload of the record
return self.handle_onwrite(record)
.pipe(function () {
.then(function () {
return self.reload_record(record); })
.pipe(function () {
.then(function () {
return { created: created, record: record }; });
});
});
@ -299,7 +299,7 @@ openerp.web.list_editable = function (instance) {
form: this.editor.form,
cancel: false
}, function () {
return this.editor.cancel(force).pipe(function (attrs) {
return this.editor.cancel(force).then(function (attrs) {
if (attrs.id) {
var record = self.records.get(attrs.id);
if (!record) {
@ -343,7 +343,7 @@ openerp.web.list_editable = function (instance) {
message: _.str.sprintf("Event %s:before cancelled",
event_name)});
}
return $.when(action.call(this)).then(function () {
return $.when(action.call(this)).done(function () {
self.trigger.apply(self, [event_name + ':after']
.concat(_.toArray(arguments)));
});
@ -373,7 +373,7 @@ openerp.web.list_editable = function (instance) {
var on_write_callback = self.fields_view.arch.attrs.on_write;
if (!on_write_callback) { return $.when(); }
return this.dataset.call(on_write_callback, [source_record.get('id')])
.pipe(function (ids) {
.then(function (ids) {
return $.when.apply(
null, _(ids).map(
_.bind(self.handle_onwrite_record, self, source_record)));
@ -434,7 +434,7 @@ openerp.web.list_editable = function (instance) {
_next: function (next_record, options) {
next_record = next_record || 'succ';
var self = this;
return this.save_edition().pipe(function (saveInfo) {
return this.save_edition().then(function (saveInfo) {
if (saveInfo.created) {
return self.start_edition();
}
@ -638,7 +638,7 @@ openerp.web.list_editable = function (instance) {
var _super = this._super();
this.form.embedded_view = this._validate_view(
this.delegate.edition_view(this));
var form_ready = this.form.appendTo(this.$el).then(
var form_ready = this.form.appendTo(this.$el).done(
self.form.proxy('do_hide'));
return $.when(_super, form_ready);
},
@ -719,9 +719,9 @@ openerp.web.list_editable = function (instance) {
var loaded = record
? form.trigger('load_record', _.extend({}, record))
: form.load_defaults();
return $.when(loaded).pipe(function () {
return $.when(loaded).then(function () {
return form.do_show({reload: false});
}).pipe(function () {
}).then(function () {
self.record = form.datarecord;
_(form.fields).each(function (field, name) {
configureField(name, field);
@ -734,7 +734,7 @@ openerp.web.list_editable = function (instance) {
var self = this;
return this.form
.save(this.delegate.prepends_on_create())
.pipe(function (result) {
.then(function (result) {
var created = result.created && !self.record.id;
if (created) {
self.record.id = result.result;

View File

@ -45,7 +45,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
view_type: "tree",
toolbar: this.view_manager ? !!this.view_manager.sidebar : false,
context: this.dataset.get_context()
}).then(this.on_loaded);
}).done(this.on_loaded);
},
/**
* Returns the list of fields needed to correctly read objects.
@ -92,7 +92,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
}));
this.$el.addClass(this.fields_view.arch.attrs['class']);
this.dataset.read_slice(this.fields_list()).then(function(records) {
this.dataset.read_slice(this.fields_list()).done(function(records) {
self.store_record(records);
if (!has_toolbar) {
// WARNING: will do a second read on the same ids, but only on
@ -205,7 +205,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
var parent_child ={};
id = _.isArray(id)?id:parseInt(id);
var ir_model_data = new instance.web.Model(this.model,self.dataset.get_context() || {},[['id','child_of',id]]).query();
ir_model_data._execute().then(function(records){
ir_model_data._execute().done(function(records){
self.store_record(records);
_.each(records,function(rec){
if(rec[self.children_field].length === 0)return;
@ -254,7 +254,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
model: this.dataset.model,
context: new instance.web.CompoundContext(
this.dataset.get_context(), local_context)
}).pipe(function (actions) {
}).then(function (actions) {
if (!actions.length) { return; }
var action = actions[0][2];
var c = new instance.web.CompoundContext(local_context);
@ -263,7 +263,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
}
return self.rpc('/web/session/eval_domain_and_context', {
contexts: [c], domains: []
}).pipe(function (res) {
}).then(function (res) {
action.context = res.context;
return self.do_action(action);
}, null);

View File

@ -208,7 +208,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
if (run_action) {
this.null_action();
action_loaded = this.do_action(state.action);
instance.webclient.menu.has_been_loaded.then(function() {
instance.webclient.menu.has_been_loaded.done(function() {
instance.webclient.menu.open_action(state.action);
});
}
@ -226,14 +226,14 @@ instance.web.ActionManager = instance.web.Widget.extend({
} else if (state.sa) {
// load session action
this.null_action();
action_loaded = this.rpc('/web/session/get_session_action', {key: state.sa}).pipe(function(action) {
action_loaded = this.rpc('/web/session/get_session_action', {key: state.sa}).then(function(action) {
if (action) {
return self.do_action(action);
}
});
}
$.when(action_loaded || null).then(function() {
$.when(action_loaded || null).done(function() {
if (self.inner_widget && self.inner_widget.do_load_state) {
self.inner_widget.do_load_state(state, warm);
}
@ -251,7 +251,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
return this.do_action(action_client, options);
} else if (_.isNumber(action) || _.isString(action)) {
var self = this;
return self.rpc("/web/action/load", { action_id: action }).pipe(function(result) {
return self.rpc("/web/action/load", { action_id: action }).then(function(result) {
return self.do_action(result, options);
});
}
@ -379,7 +379,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
this.rpc('/web/action/run', {
action_id: action.id,
context: action.context || {}
}).then(function (action) {
}).done(function (action) {
self.do_action(action, options)
});
},
@ -389,7 +389,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
self.rpc("/web/session/eval_domain_and_context", {
contexts: [action.context],
domains: []
}).then(function(res) {
}).done(function(res) {
action = _.clone(action);
action.context = res.context;
self.session.get_file({
@ -487,7 +487,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
} else if (this.searchview
&& self.flags.auto_search
&& view.controller.searchable !== false) {
this.searchview.ready.then(this.searchview.do_search);
this.searchview.ready.done(this.searchview.do_search);
}
if (this.searchview) {
@ -499,7 +499,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
.find('.oe_view_manager_switch a').filter('[data-view-type="' + view_type + '"]')
.parent().addClass('active');
r = $.when(view_promise).then(function () {
r = $.when(view_promise).done(function () {
_.each(_.keys(self.views), function(view_name) {
var controller = self.views[view_name].controller;
if (controller) {
@ -551,11 +551,11 @@ instance.web.ViewManager = instance.web.Widget.extend({
var view_promise = controller.appendTo(container);
this.views[view_type].controller = controller;
this.views[view_type].deferred.resolve(view_type);
return $.when(view_promise).then(function() {
return $.when(view_promise).done(function() {
if (self.searchview
&& self.flags.auto_search
&& view.controller.searchable !== false) {
self.searchview.ready.then(self.searchview.do_search);
self.searchview.ready.done(self.searchview.do_search);
}
self.trigger("controller_inited",view_type,controller);
});
@ -582,7 +582,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
var view_to_select = views[index];
var state = self.url_states[view_to_select];
self.do_push_state(state || {});
$.when(self.switch_mode(view_to_select)).then(function() {
$.when(self.switch_mode(view_to_select)).done(function() {
self.$el.show();
});
},
@ -661,7 +661,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
domains: [this.action.domain || []].concat(domains || []),
contexts: [action_context].concat(contexts || []),
group_by_seq: groupbys || []
}).then(function (results) {
}).done(function (results) {
self.dataset._model = new instance.web.Model(
self.dataset.model, results.context, results.domain);
var groupby = results.group_by.length
@ -786,7 +786,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
case 'perm_read':
var ids = current_view.get_selected_ids();
if (ids.length === 1) {
this.dataset.call('perm_read', [ids]).then(function(result) {
this.dataset.call('perm_read', [ids]).done(function(result) {
var dialog = new instance.web.Dialog(this, {
title: _.str.sprintf(_t("View Log (%s)"), self.dataset.model),
width: 400
@ -812,7 +812,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
});
break;
case 'fields':
this.dataset.call('fields_get', [false, {}]).then(function (fields) {
this.dataset.call('fields_get', [false, {}]).done(function (fields) {
var $root = $('<dl>');
_(fields).each(function (attributes, name) {
$root.append($('<dt>').append($('<h4>').text(name)));
@ -899,7 +899,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
switch_mode: function (view_type, no_store, options) {
var self = this;
return $.when(this._super.apply(this, arguments)).then(function () {
return $.when(this._super.apply(this, arguments)).done(function () {
var controller = self.views[self.active_view].controller;
self.$el.find('.oe_debug_view').html(QWeb.render('ViewManagerDebug', {
view: controller,
@ -938,13 +938,13 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
defs = [];
if (state.view_type && state.view_type !== this.active_view) {
defs.push(
this.views[this.active_view].deferred.pipe(function() {
this.views[this.active_view].deferred.then(function() {
return self.switch_mode(state.view_type, true);
})
);
}
$.when(defs).then(function() {
$.when(defs).done(function() {
self.views[self.active_view].controller.do_load_state(state, warm);
});
},
@ -1051,7 +1051,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
},
on_item_action_clicked: function(item) {
var self = this;
self.getParent().sidebar_context().then(function (context) {
self.getParent().sidebar_context().done(function (context) {
var ids = self.getParent().get_selected_ids();
if (ids.length == 0) {
instance.web.dialog($("<div />").text(_t("You must choose at least one record.")), { title: _t("Warning"), modal: true });
@ -1065,7 +1065,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
self.rpc("/web/action/load", {
action_id: item.action.id,
context: additional_context
}).then(function(result) {
}).done(function(result) {
result.context = _.extend(result.context || {},
additional_context);
result.flags = result.flags || {};
@ -1087,7 +1087,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
} else {
var dom = [ ['res_model', '=', dataset.model], ['res_id', '=', model_id], ['type', 'in', ['binary', 'url']] ];
var ds = new instance.web.DataSetSearch(this, 'ir.attachment', dataset.get_context(), dom);
ds.read_slice(['name', 'url', 'type'], {}).then(this.on_attachments_loaded);
ds.read_slice(['name', 'url', 'type'], {}).done(this.on_attachments_loaded);
}
},
on_attachments_loaded: function(attachments) {
@ -1122,7 +1122,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
var self = this;
var $e = $(e.currentTarget);
if (confirm(_t("Do you really want to delete this attachment ?"))) {
(new instance.web.DataSet(this, 'ir.attachment')).unlink([parseInt($e.attr('data-id'), 10)]).then(function() {
(new instance.web.DataSet(this, 'ir.attachment')).unlink([parseInt($e.attr('data-id'), 10)]).done(function() {
self.do_attachement_update(self.dataset, self.model_id);
});
}
@ -1150,7 +1150,7 @@ instance.web.View = instance.web.Widget.extend({
var view_loaded;
if (this.embedded_view) {
view_loaded = $.Deferred();
$.async_when().then(function() {
$.async_when().done(function() {
view_loaded.resolve(self.embedded_view);
});
} else {
@ -1164,7 +1164,7 @@ instance.web.View = instance.web.Widget.extend({
context: this.dataset.get_context(context)
});
}
return view_loaded.pipe(function(r) {
return view_loaded.then(function(r) {
self.trigger('view_loaded', r);
// add css classes that reflect the (absence of) access rights
self.$el.addClass('oe_view')
@ -1220,7 +1220,7 @@ instance.web.View = instance.web.Widget.extend({
return self.rpc('/web/session/eval_domain_and_context', {
contexts: [ncontext],
domains: []
}).pipe(function (results) {
}).then(function (results) {
action.context = results.context;
/* niv: previously we were overriding once more with action_data.context,
* I assumed this was not a correct behavior and removed it
@ -1249,11 +1249,11 @@ instance.web.View = instance.web.Widget.extend({
}
}
args.push(context);
return dataset.call_button(action_data.name, args).then(handler);
return dataset.call_button(action_data.name, args).done(handler);
} else if (action_data.type=="action") {
return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}).then(handler);
return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}).done(handler);
} else {
return dataset.exec_workflow(record_id, action_data.name).then(handler);
return dataset.exec_workflow(record_id, action_data.name).done(handler);
}
},
/**

View File

@ -82,7 +82,7 @@ $(document).ready(function () {
});
t.test('call', function (openerp) {
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
t.expect(ds.call('frob', ['a', 'b', 42]).then(function (r) {
t.expect(ds.call('frob', ['a', 'b', 42]).done(function (r) {
strictEqual(r.method, 'frob');
strictEqual(r.args.length, 3);
@ -91,7 +91,7 @@ $(document).ready(function () {
ok(_.isEmpty(r.kwargs));
}));
});
t.test('name_get').then(function (openerp) {
t.test('name_get').done(function (openerp) {
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
t.expect(ds.name_get([1, 2], null), function (r) {
strictEqual(r.method, 'name_get');

View File

@ -107,12 +107,12 @@ $(document).ready(function () {
});
var counter = 0;
e.appendTo($fix)
.pipe(function () {
.then(function () {
return e.edit({}, function () {
++counter;
});
})
.pipe(function (form) {
.then(function (form) {
ok(e.is_editing(), "should be editing");
equal(counter, 3, "should have configured all fields");
return e.save();
@ -137,12 +137,12 @@ $(document).ready(function () {
});
var counter = 0;
e.appendTo($fix)
.pipe(function () {
.then(function () {
return e.edit({}, function () {
++counter;
});
})
.pipe(function (form) {
.then(function (form) {
return e.cancel();
})
.always(start)
@ -170,12 +170,12 @@ $(document).ready(function () {
var counter = 0;
var warnings = 0;
e.appendTo($fix)
.pipe(function () {
.then(function () {
return e.edit({}, function () {
++counter;
});
})
.pipe(function (form) {
.then(function (form) {
return e.save();
})
.always(start)
@ -243,16 +243,16 @@ $(document).ready(function () {
var l = new instance.web.ListView({}, ds, false, {editable: 'top'});
l.appendTo($fix)
.pipe(l.proxy('reload_content'))
.pipe(function () {
.then(l.proxy('reload_content'))
.then(function () {
return l.start_edition();
})
.always(start)
.pipe(function () {
.then(function () {
ok(got_defaults, "should have fetched default values for form");
return l.save_edition();
})
.pipe(function (result) {
.then(function (result) {
ok(result.created, "should yield newly created record");
equal(result.record.get('a'), "qux",
"should have used default values");
@ -307,14 +307,14 @@ $(document).ready(function () {
var l = new instance.web.ListView({}, ds, false, {editable: 'top'});
l.on('edit:before edit:after', o, o.onEvent);
l.appendTo($fix)
.pipe(l.proxy('reload_content'))
.then(l.proxy('reload_content'))
.always(start)
.pipe(function () {
.then(function () {
ok(l.options.editable, "should be editable");
equal(o.counter, 0, "should have seen no event yet");
return l.start_edition(l.records.get(1));
})
.pipe(function () {
.then(function () {
ok(l.editor.is_editing(), "should be editing");
equal(o.counter, 2, "should have seen two edition events");
})
@ -332,14 +332,14 @@ $(document).ready(function () {
edit_after = true;
});
l.appendTo($fix)
.pipe(l.proxy('reload_content'))
.then(l.proxy('reload_content'))
.always(start)
.pipe(function () {
.then(function () {
ok(l.options.editable, "should be editable");
return l.start_edition();
})
// cancelling an event rejects the deferred
.pipe($.Deferred().reject(), function () {
.then($.Deferred().reject(), function () {
ok(!l.editor.is_editing(), "should not be editing");
ok(!edit_after, "should not have fired the edit:after event");
return $.when();

View File

@ -29,10 +29,10 @@ $(document).ready(function () {
fail1 = false, fail2 = false;
var d1 = $.Deferred(), d2 = $.Deferred();
dm.add(d1).then(function () { done1 = true; },
function () { fail1 = true; });
dm.add(d2).then(function () { done2 = true; },
function () { fail2 = true; });
dm.add(d1).done(function () { done1 = true; }
.fail(function () { fail1 = true; });
dm.add(d2).done(function () { done2 = true; })
.fail(function () { fail2 = true; });
d2.resolve();
d1.resolve();
@ -50,10 +50,10 @@ $(document).ready(function () {
fail1 = false, fail2 = false;
var d1 = $.Deferred(), d2 = $.Deferred();
dm.add(d1).then(function () { done1 = true; },
function () { fail1 = true; });
dm.add(d2).then(function () { done2 = true; },
function () { fail2 = true; });
dm.add(d1).done(function () { done1 = true; })
.fail(function () { fail1 = true; });
dm.add(d2).done(function () { done2 = true; })
.fail(function () { fail2 = true; });
d2.resolve();
d1.resolve();
@ -86,10 +86,10 @@ $(document).ready(function () {
fail1 = false, fail2 = false;
var d1 = $.Deferred(), d2 = $.Deferred();
dm.add(d1).then(function () { done1 = true; },
function () { fail1 = true; });
dm.add(d2).then(function () { done2 = true; },
function () { fail2 = true; });
dm.add(d1).done(function () { done1 = true; })
.fail(function () { fail1 = true; });
dm.add(d2).done(function () { done2 = true; })
.fail(function () { fail2 = true; });
setTimeout(function () { d1.resolve(); }, 200);
setTimeout(function () { d2.resolve(); }, 100);
@ -110,10 +110,10 @@ $(document).ready(function () {
fail1 = false, fail2 = false;
var d1 = $.Deferred(), d2 = $.Deferred();
dm.add(d1).then(function () { done1 = true; },
function () { fail1 = true; });
dm.add(d2).then(function () { done2 = true; },
function () { fail2 = true; });
dm.add(d1).done(function () { done1 = true; })
.fail(function () { fail1 = true; });
dm.add(d2).done(function () { done2 = true; })
.fail(function () { fail2 = true; });
setTimeout(function () { d1.resolve(); }, 200);
setTimeout(function () { d2.resolve(); }, 100);

View File

@ -43,7 +43,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
},
start: function() {
this._super();
return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': false}).then(this.on_loaded);
return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': false}).done(this.on_loaded);
},
destroy: function() {
scheduler.clearAll();
@ -106,7 +106,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
if (!this.sidebar && this.options.$sidebar) {
this.sidebar = new instance.web_calendar.Sidebar(this);
this.has_been_loaded.pipe(this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container')));
this.has_been_loaded.then(this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container')));
}
this.trigger('calendar_view_loaded', data);
return this.has_been_loaded.resolve();
@ -214,7 +214,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
}
},
reload_event: function(id) {
this.dataset.read_ids([id], _.keys(this.fields)).then(this.on_events_loaded);
this.dataset.read_ids([id], _.keys(this.fields)).done(this.on_events_loaded);
},
get_color: function(key) {
if (this.color_map[key]) {
@ -307,20 +307,20 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
do_create_event: function(event_id, event_obj) {
var self = this,
data = this.get_event_data(event_obj);
this.dataset.create(data).then(function(r) {
this.dataset.create(data).done(function(r) {
var id = r;
self.dataset.ids.push(id);
scheduler.changeEventId(event_id, id);
self.refresh_minical();
self.reload_event(id);
}, function(r, event) {
}).fail(function(r, event) {
event.preventDefault();
self.do_create_event_with_formdialog(event_id, event_obj);
});
},
do_create_event_with_formdialog: function(event_id, event_obj) {
var self = this;
$.when(! self.form_dialog.dialog_inited ? self.form_dialog.init_dialog() : true).then(function() {
$.when(! self.form_dialog.dialog_inited ? self.form_dialog.init_dialog() : true).done(function() {
if (!event_obj) {
event_obj = scheduler.getEvent(event_id);
}
@ -328,13 +328,13 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
fields_to_fetch = _(self.form_dialog.form.fields_view.fields).keys();
self.dataset.index = null;
self.creating_event_id = event_id;
self.form_dialog.form.do_show().then(function() {
self.form_dialog.form.do_show().done(function() {
_.each(['date_start', 'date_delay', 'date_stop'], function(field) {
var field_name = self[field];
if (field_name && self.form_dialog.form.fields[field_name]) {
var ffield = self.form_dialog.form.fields[field_name];
ffield._dirty_flag = false;
$.when(ffield.set_value(data[field_name])).then(function() {
$.when(ffield.set_value(data[field_name])).done(function() {
ffield._dirty_flag = true;
self.form_dialog.form.do_onchange(ffield);
});
@ -350,7 +350,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
index = this.dataset.get_id_index(event_id);
if (index != null) {
event_id = this.dataset.ids[index];
this.dataset.write(event_id, data, {}).then(function() {
this.dataset.write(event_id, data, {}).done(function() {
self.refresh_minical();
});
}
@ -361,7 +361,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
var self = this,
index = this.dataset.get_id_index(event_id);
if (index !== null) {
this.dataset.unlink(event_id).then(function() {
this.dataset.unlink(event_id).done(function() {
self.refresh_minical();
});
}
@ -413,12 +413,12 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
do_ranged_search: function() {
var self = this;
scheduler.clearAll();
$.when(this.has_been_loaded, this.ready).then(function() {
$.when(this.has_been_loaded, this.ready).done(function() {
self.dataset.read_slice(_.keys(self.fields), {
offset: 0,
domain: self.get_range_domain(),
context: self.last_search[1]
}).then(function(events) {
}).done(function(events) {
self.dataset_events = events;
self.on_events_loaded(events);
});
@ -433,7 +433,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({
},
do_show: function () {
var self = this;
$.when(this.has_been_loaded).then(function() {
$.when(this.has_been_loaded).done(function() {
self.$el.show();
self.do_push_state({});
});

View File

@ -25,7 +25,7 @@ instance.web.DiagramView = instance.web.View.extend({
},
start: function() {
var self = this;
return this.rpc("/web_diagram/diagram/load", {"model": this.model, "view_id": this.view_id}).then(function(r) {
return this.rpc("/web_diagram/diagram/load", {"model": this.model, "view_id": this.view_id}).done(function(r) {
self.load_diagram(r);
});
},
@ -109,7 +109,7 @@ instance.web.DiagramView = instance.web.View.extend({
});
this.rpc(
'/web_diagram/diagram/get_diagram_info',params).then(function(result) {
'/web_diagram/diagram/get_diagram_info',params).done(function(result) {
self.draw_diagram(result);
}
);
@ -260,7 +260,7 @@ instance.web.DiagramView = instance.web.View.extend({
);
pop.on('write_completed', self, function() {
self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_diagram_loaded);
self.dataset.read_index(_.keys(self.fields_view.fields)).then(self.on_diagram_loaded);
});
var form_fields = [self.parent_field];
@ -294,7 +294,7 @@ instance.web.DiagramView = instance.web.View.extend({
self.context || self.dataset.context
);
pop.on("elements_selected", self, function(element_ids) {
self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_diagram_loaded);
self.dataset.read_index(_.keys(self.fields_view.fields)).then(self.on_diagram_loaded);
});
var form_controller = pop.view_form;
@ -324,7 +324,7 @@ instance.web.DiagramView = instance.web.View.extend({
}
);
pop.on('write_completed', self, function() {
self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_diagram_loaded);
self.dataset.read_index(_.keys(self.fields_view.fields)).then(self.on_diagram_loaded);
});
},
@ -346,7 +346,7 @@ instance.web.DiagramView = instance.web.View.extend({
this.context || this.dataset.context
);
pop.on("elements_selected", self, function(element_ids) {
self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_diagram_loaded);
self.dataset.read_index(_.keys(self.fields_view.fields)).then(self.on_diagram_loaded);
});
// We want to destroy the dummy edge after a creation cancel. This destroys it even if we save the changes.
// This is not a problem since the diagram is completely redrawn on saved changes.
@ -383,7 +383,7 @@ instance.web.DiagramView = instance.web.View.extend({
break;
}
var loaded = this.dataset.read_index(_.keys(this.fields_view.fields))
.pipe(this.on_diagram_loaded);
.then(this.on_diagram_loaded);
this.do_update_pager();
return loaded;
},

View File

@ -87,12 +87,12 @@
dummy_circle.animate({'r': close_button_radius }, 400, 'linear');
if(entity_type == "node"){
$.when(GraphNode.destruction_callback(entity)).then(function () {
$.when(GraphNode.destruction_callback(entity)).done(function () {
//console.log("remove node",entity);
entity.remove();
});
}else if(entity_type == "edge"){
$.when(GraphEdge.destruction_callback(entity)).then(function () {
$.when(GraphEdge.destruction_callback(entity)).done(function () {
//console.log("remove edge",entity);
entity.remove();
});

View File

@ -22,7 +22,7 @@ instance.web_gantt.GanttView = instance.web.View.extend({
var self = this;
this.fields_view = fields_view_get;
this.$el.addClass(this.fields_view.arch.attrs['class']);
return this.rpc("/web/searchview/fields_get", {"model": this.dataset.model}).pipe(function(fields_get) {
return this.rpc("/web/searchview/fields_get", {"model": this.dataset.model}).then(function(fields_get) {
self.fields = fields_get.fields;
self.has_been_loaded.resolve();
});
@ -46,11 +46,11 @@ instance.web_gantt.GanttView = instance.web.View.extend({
}));
fields = _.uniq(fields.concat(n_group_bys));
return $.when(this.has_been_loaded).pipe(function() {
return $.when(this.has_been_loaded).then(function() {
return self.dataset.read_slice(fields, {
domain: domains,
context: contexts
}).pipe(function(data) {
}).then(function(data) {
return self.on_data_loaded(data, n_group_bys);
});
});
@ -62,7 +62,7 @@ instance.web_gantt.GanttView = instance.web.View.extend({
on_data_loaded: function(tasks, group_bys) {
var self = this;
var ids = _.pluck(tasks, "id");
return this.dataset.name_get(ids).pipe(function(names) {
return this.dataset.name_get(ids).then(function(names) {
var ntasks = _.map(tasks, function(task) {
return _.extend({__name: _.detect(names, function(name) { return name[0] == task.id; })[1]}, task);
});

View File

@ -94,7 +94,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
if (self.legend == "top") { self.legend = "inside"; }
self.forcehtml = true;
self.graph_get_data().then(function (result) {
self.graph_get_data().done(function (result) {
self.graph_render_all(result).download.saveImage('png');
}).always(function () {
self.forcehtml = false;
@ -243,7 +243,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
var result = [];
var ticks = {};
return obj.call("fields_view_get", [view_id, 'graph']).pipe(function(tmp) {
return obj.call("fields_view_get", [view_id, 'graph']).then(function(tmp) {
view_get = tmp;
fields = view_get['fields'];
var toload = _.select(group_by, function(x) { return fields[x] === undefined });
@ -251,7 +251,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
return obj.call("fields_get", [toload, context]);
else
return $.when([]);
}).pipe(function (fields_to_add) {
}).then(function (fields_to_add) {
_.extend(fields, fields_to_add);
var tree = $($.parseXML(view_get['arch']));
@ -307,7 +307,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
}
if (mode === "pie") {
return obj.call("read_group", [domain, yaxis.concat([xaxis[0]]), [xaxis[0]]], {context: context}).pipe(function(res) {
return obj.call("read_group", [domain, yaxis.concat([xaxis[0]]), [xaxis[0]]], {context: context}).then(function(res) {
_.each(res, function(record) {
result.push({
'data': [[_convert(xaxis[0], record[xaxis[0]]), record[yaxis[0]]]],
@ -318,11 +318,11 @@ instance.web_graph.GraphView = instance.web.View.extend({
} else if ((! stacked) || (xaxis.length < 2)) {
var defs = [];
_.each(xaxis, function(x) {
defs.push(obj.call("read_group", [domain, yaxis.concat([x]), [x]], {context: context}).pipe(function(res) {
defs.push(obj.call("read_group", [domain, yaxis.concat([x]), [x]], {context: context}).then(function(res) {
return [x, res];
}));
});
return $.when.apply($, defs).pipe(function() {
return $.when.apply($, defs).then(function() {
_.each(_.toArray(arguments), function(res) {
var x = res[0];
res = res[1];
@ -336,16 +336,16 @@ instance.web_graph.GraphView = instance.web.View.extend({
});
} else {
xaxis.reverse();
return obj.call("read_group", [domain, yaxis.concat(xaxis.slice(0, 1)), xaxis.slice(0, 1)], {context: context}).pipe(function(axis) {
return obj.call("read_group", [domain, yaxis.concat(xaxis.slice(0, 1)), xaxis.slice(0, 1)], {context: context}).then(function(axis) {
var defs = [];
_.each(axis, function(x) {
var key = x[xaxis[0]]
defs.push(obj.call("read_group", [new instance.web.CompoundDomain(domain, [[xaxis[0], '=' ,_convert_key(xaxis[0], key)]]),
yaxis.concat(xaxis.slice(1, 2)), xaxis.slice(1, 2)], {context: context}).pipe(function(res) {
yaxis.concat(xaxis.slice(1, 2)), xaxis.slice(1, 2)], {context: context}).then(function(res) {
return [x, key, res];
}));
});
return $.when.apply($, defs).pipe(function() {
return $.when.apply($, defs).then(function() {
_.each(_.toArray(arguments), function(res) {
var x = res[0];
var key = res[1];
@ -360,7 +360,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
});
});
}
}).pipe(function() {
}).then(function() {
var res = {
'data': result,
'ticks': _.map(ticks, function(el, key) { return [el, key] })
@ -375,7 +375,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
_.extend(this, options.data);
return this.graph_get_data()
.then(this.proxy('graph_render_all'));
.done(this.proxy('graph_render_all'));
},
graph_render_all: function (data) {

View File

@ -198,7 +198,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var form = am.dialog_widget.views.form.controller;
form.on("on_button_cancel", am.dialog, am.dialog.close);
form.on('record_created', self, function(r) {
(new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r]).then(function(new_record) {
(new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r]).done(function(new_record) {
am.dialog.close();
var domain = self.dataset.domain.slice(0);
domain.push([self.group_by, '=', new_record[0][0]]);
@ -212,7 +212,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
aggregates: {},
};
var new_group = new instance.web_kanban.KanbanGroup(self, [], datagroup, dataset);
self.do_add_groups([new_group]).then(function() {
self.do_add_groups([new_group]).done(function() {
$(window).scrollTo(self.groups.slice(-1)[0].$el, { axis: 'x' });
});
});
@ -224,14 +224,14 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
this.search_domain = domain;
this.search_context = context;
this.search_group_by = group_by;
$.when(this.has_been_loaded).then(function() {
$.when(this.has_been_loaded).done(function() {
self.group_by = group_by.length ? group_by[0] : self.fields_view.arch.attrs.default_group_by;
self.group_by_field = self.fields_view.fields[self.group_by] || {};
self.grouped_by_m2o = (self.group_by_field.type === 'many2one');
self.$buttons.find('.oe_alternative').toggle(self.grouped_by_m2o);
self.$el.toggleClass('oe_kanban_grouped_by_m2o', self.grouped_by_m2o);
var grouping = new instance.web.Model(self.dataset.model, context, domain).query().group_by(self.group_by);
$.when(grouping).then(function(groups) {
$.when(grouping).done(function(groups) {
if (groups) {
self.do_process_groups(groups);
} else {
@ -252,7 +252,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
new instance.web.CompoundContext(self.dataset.get_context(), group.model.context()), group.model.domain());
return dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit })
.pipe(function(records) {
.then(function(records) {
self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
if (!remaining--) {
@ -268,16 +268,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
this.add_group_mutex.exec(function() {
var def = $.Deferred();
self.dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).then(function(records) {
self.dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).done(function(records) {
self.do_clear_groups();
var kgroup = new instance.web_kanban.KanbanGroup(self, records, null, self.dataset);
self.do_add_groups([kgroup]).then(function() {
self.do_add_groups([kgroup]).done(function() {
if (_.isEmpty(records)) {
self.no_result();
}
def.resolve();
});
}).then(null, function() {
}).done(null, function() {
def.reject();
});
return def;
@ -306,7 +306,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
return group.insertBefore($last_td);
}
});
return $.when.apply(null, groups_started).then(function () {
return $.when.apply(null, groups_started).done(function () {
self.on_groups_started();
self.$el.appendTo($parent);
_.each(self.groups, function(group) {
@ -375,7 +375,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var tmp_group = self.groups.splice(start_index, 1)[0];
self.groups.splice(stop_index, 0, tmp_group);
var new_sequence = _.pluck(self.groups, 'value');
(new instance.web.DataSet(self, self.group_by_field.relation)).resequence(new_sequence).then(function(r) {
(new instance.web.DataSet(self, self.group_by_field.relation)).resequence(new_sequence).done(function(r) {
if (r === false) {
console.error("Kanban: could not resequence model '%s'. Probably no 'sequence' field.", self.group_by_field.relation);
}
@ -404,7 +404,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
record.group = new_group;
var data = {};
data[this.group_by] = new_group.value;
this.dataset.write(record.id, data, {}).then(function() {
this.dataset.write(record.id, data, {}).done(function() {
record.do_reload();
new_group.do_save_sequences();
}).fail(function(error, evt) {
@ -497,7 +497,7 @@ instance.web_kanban.KanbanView.postprocessing_widget_many2many_tags = function(s
if(model_list_id[model].length>0){
var block = self.$el.find(".oe_form_field.oe_tags[model='" + model + "']");
var dataset = new instance.web.DataSetSearch(self, model, self.session.context);
dataset.name_get(_.uniq( model_list_id[model] )).then(
dataset.name_get(_.uniq( model_list_id[model] )).done(
function(result) {
for(var t=0;t<result.length;t++){
block.filter(function(){ return this.getAttribute("data").match(new RegExp('(^|,)'+result[t][0]+'(,|$)')); })
@ -557,7 +557,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
this.$records = null;
this.records = [];
this.$has_been_started.then(function() {
this.$has_been_started.done(function() {
self.do_add_records(records);
});
},
@ -641,7 +641,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
this.dataset.read_slice(this.view.fields_keys.concat(['__last_update']), {
'limit': self.view.limit,
'offset': self.dataset_offset += self.view.limit
}).then(this.do_add_records);
}).done(this.do_add_records);
},
do_add_records: function(records, prepend) {
var self = this;
@ -704,7 +704,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
do_action_delete: function() {
var self = this;
if (confirm(_t("Are you sure to remove this column ?"))) {
(new instance.web.DataSet(self, self.view.group_by_field.relation)).unlink([self.value]).then(function(r) {
(new instance.web.DataSet(self, self.view.group_by_field.relation)).unlink([self.value]).done(function(r) {
self.view.do_reload();
});
}
@ -724,7 +724,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
quick_created: function (record) {
var id = record, self = this;
this.dataset.read_ids([id], this.view.fields_keys)
.then(function (records) {
.done(function (records) {
self.view.dataset.ids.push(id);
self.do_add_records(records, true);
});
@ -899,7 +899,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
var color_field = $(this).parents('.oe_kanban_colorpicker').first().data('field') || 'color';
var data = {};
data[color_field] = $(this).data('color');
self.view.dataset.write(self.id, data, {}).then(function() {
self.view.dataset.write(self.id, data, {}).done(function() {
self.record[color_field] = $(this).data('color');
self.do_reload();
});
@ -909,7 +909,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
do_action_delete: function($action) {
var self = this;
function do_it() {
return $.when(self.view.dataset.unlink([self.id])).then(function() {
return $.when(self.view.dataset.unlink([self.id])).done(function() {
self.group.remove_record(self.id);
self.destroy();
});
@ -933,7 +933,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
},
do_reload: function() {
var self = this;
this.view.dataset.read_ids([this.id], this.view.fields_keys.concat(['__last_update'])).then(function(records) {
this.view.dataset.read_ids([this.id], this.view.fields_keys.concat(['__last_update'])).done(function(records) {
if (records.length) {
self.set_record(records[0]);
self.renderElement();
@ -1063,7 +1063,7 @@ instance.web_kanban.QuickCreate = instance.web.Widget.extend({
this._dataset.call(
'name_create', [self.$input.val() || false, new instance.web.CompoundContext(
this._dataset.get_context(), this._context)])
.pipe(function(record) {
.then(function(record) {
self.$input.val("");
self.trigger('added', record[0]);
}, function(error, event) {

View File

@ -18,7 +18,7 @@ openerp.web_tests = function (instance) {
start: function () {
$.when(
this.dataset.read_slice(),
this.form.appendTo(this.$el)).then(this.on_everything_loaded);
this.form.appendTo(this.$el)).done(this.on_everything_loaded);
},
on_everything_loaded: function (slice) {
var records = slice[0].records;

View File

@ -71,7 +71,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
this.main_view_id = this.parent.fields_view.view_id;
this.action_manager = new instance.web.ActionManager(this);
this.action_manager.appendTo(this.view_edit_dialog.$el);
$.when(this.action_manager.do_action(action)).then(function() {
$.when(this.action_manager.do_action(action)).done(function() {
var viewmanager = self.action_manager.inner_widget;
var controller = viewmanager.views[viewmanager.active_view].controller;
controller.on('view_loaded', function(){
@ -103,7 +103,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
if (warn) {
self.on_valid_create_view(self.create_view_widget);
} else {
$.when(self.do_save_view(view_values)).then(function() {
$.when(self.do_save_view(view_values)).done(function() {
self.create_view_dialog.close();
var controller = self.action_manager.inner_widget.views[self.action_manager.inner_widget.active_view].controller;
controller.reload_content();
@ -136,7 +136,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
var field_dataset = new instance.web.DataSetSearch(this, this.model, null, null);
var model_dataset = new instance.web.DataSetSearch(this, 'ir.model', null, null);
var view_string = "", field_name = false, self = this;
field_dataset.call( 'fields_get', []).then(function(fields) {
field_dataset.call( 'fields_get', []).done(function(fields) {
_.each(['name', 'x_name'], function(value) {
if (_.include(_.keys(fields), value)) {
field_name = value;
@ -144,7 +144,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
}
});
if (field_name) {
model_dataset.read_slice(['name','field_id'], {"domain": [['model','=',self.model]]}).then(function(records) {
model_dataset.read_slice(['name','field_id'], {"domain": [['model','=',self.model]]}).done(function(records) {
if (records) {view_string = records[0].name;}
var arch = _.str.sprintf("<?xml version='1.0'?>\n<%s string='%s'>\n\t<field name='%s'/>\n</%s>", values.view_type, view_string, field_name, values.view_type);
var vals = {'model': self.model, 'name': values.view_name, 'priority': values.priority, 'type': values.view_type, 'arch': arch};
@ -183,7 +183,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
var self = this;
if (confirm(_t("Do you really want to remove this view?"))) {
var controller = this.action_manager.inner_widget.views[this.action_manager.inner_widget.active_view].controller;
this.dataset.unlink([this.main_view_id]).then(function() {
this.dataset.unlink([this.main_view_id]).done(function() {
controller.reload_content();
self.main_view_id = self.parent.fields_view.view_id;
});
@ -246,12 +246,12 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
get_arch: function() {
var self = this;
var view_arch_list = [];
this.dataset.read_ids([parseInt(self.main_view_id)], ['arch', 'type','priority']).then(function(arch) {
this.dataset.read_ids([parseInt(self.main_view_id)], ['arch', 'type','priority']).done(function(arch) {
if (arch.length) {
var arch_object = self.parse_xml(arch[0].arch, self.main_view_id);
self.main_view_type = arch[0].type == 'tree'? 'list': arch[0].type;
view_arch_list.push({"view_id": self.main_view_id, "arch": arch[0].arch,"priority":arch[0].priority});
self.dataset.read_slice([], {domain: [['inherit_id','=', parseInt(self.main_view_id)]]}).then(function(result) {
self.dataset.read_slice([], {domain: [['inherit_id','=', parseInt(self.main_view_id)]]}).done(function(result) {
_.each(result, function(res) {
view_arch_list.push({"view_id": res.id, "arch": res.arch,"priority":res.priority});
self.inherit_view(arch_object, res);
@ -456,7 +456,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
var priority = _.detect(self.one_object['arch'], function(val) {return val.view_id == view_id;});
var arch = _.str.sprintf("<?xml version='1.0'?>\n\t <field name='%s' position='after'> </field>", val[1]);
var vals = {'model': self.model, 'name': view_name, 'priority': priority.priority + 1, 'type': "form", 'arch': arch,'inherit_id':self.main_view_id};
this.dataset.create(vals).then(function(id) {
this.dataset.create(vals).done(function(id) {
var arch_to_obj = self.parse_xml(arch,id);
obj.child_id.push(arch_to_obj[0]);
self.one_object['parent_child_id'] = self.parent_child_list(self.one_object['main_object'],[]);
@ -539,7 +539,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
var value = _.has(_CHILDREN, element) ? element : _.str.include(html_tag, element)?"html_tag":false;
property_to_check.push(value);
});
field_dataset.call( 'fields_get', []).then(function(result) {
field_dataset.call( 'fields_get', []).done(function(result) {
var fields = _.keys(result);
fields.push(" "),fields.sort();
self.on_add_node(property_to_check, fields);
@ -891,7 +891,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
var arch_val = self.get_object_by_id(this.one_object.clicked_tr_id,this.one_object['main_object'], []);
this.edit_node_dialog.$el.append('<table id="rec_table" style="width:400px" class="oe_form"></table>');
this.edit_widget = [];
self.ready = $.when(self.on_groups(properties)).then(function () {
self.ready = $.when(self.on_groups(properties)).done(function () {
_PROPERTIES_ATTRIBUTES['groups']['selection'] = self.groups;
var values = _.keys( instance.web.form.widgets.map);
values.push('');
@ -994,7 +994,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
table_selector.find("td[id^=]").attr("width","100px");
self.add_node_dialog.$el.find('#new_field').click(function() {
model_data = new instance.web.DataSetSearch(self,'ir.model', null, null);
model_data.read_slice([], {domain: [['model','=', self.model]]}).then(function(result) {
model_data.read_slice([], {domain: [['model','=', self.model]]}).done(function(result) {
self.render_new_field(result[0]);
});
});
@ -1012,7 +1012,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({
}
};
var action_manager = new instance.web.ActionManager(self);
$.when(action_manager.do_action(action)).then(function() {
$.when(action_manager.do_action(action)).done(function() {
var controller = action_manager.dialog_widget.views['form'].controller;
controller.on("on_button_cancel", self, function(){
action_manager.destroy();