diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 6cf35a14e92..1a44a61af07 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -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, diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index d9b7ab8c03c..d2e94d37939 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -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(); diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 220b9b63d5c..b7dac303520 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -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); diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index e279ade6fb3..467b74040c7 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -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); }); diff --git a/addons/web/static/src/js/data_export.js b/addons/web/static/src/js/data_export.js index b4beb4c3a58..477d89c99b3 100644 --- a/addons/web/static/src/js/data_export.js +++ b/addons/web/static/src/js/data_export.js @@ -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); }); diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 520dcd9169f..f229c31229b 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -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({ $('x') .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(); }); }, diff --git a/addons/web/static/src/js/test_support.js b/addons/web/static/src/js/test_support.js index 8e1317ba2b0..90173f89845 100644 --- a/addons/web/static/src/js/test_support.js +++ b/addons/web/static/src/js/test_support.js @@ -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); diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 92e636b2216..66ba41ec0cf 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -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}); }); }, diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 5546105e901..86eb4c72674 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -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()); diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index acc1d781976..92a314a9e03 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -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; diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js index 05760420ba8..f8ab343b153 100644 --- a/addons/web/static/src/js/view_tree.js +++ b/addons/web/static/src/js/view_tree.js @@ -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); diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index ebc7c326724..6e62dc70dd4 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -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 = $('