From a55cc6072a888deb871c2a25987454695d3f94b6 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 28 Sep 2012 01:45:13 +0200 Subject: [PATCH] [IMP] callback2deferred part1 dataset.unlink bzr revid: al@openerp.com-20120927234513-3aohele9gcoxkha4 --- addons/web/static/src/js/data.js | 16 ++++++---------- addons/web_calendar/static/src/js/calendar.js | 2 +- .../web_view_editor/static/src/js/view_editor.js | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 55f152857c5..55bc9239536 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -664,10 +664,8 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * @param {Function} callback function called with operation result * @param {Function} error_callback function called in case of deletion error */ - unlink: function(ids, callback, error_callback) { - return this._model.call('unlink', - [ids], {context: this._model.context()}) - .then(callback, error_callback); + unlink: function(ids) { + return this._model.call('unlink', [ids], {context: this._model.context()}); }, /** * Calls an arbitrary RPC method @@ -889,7 +887,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ }, unlink: function(ids, callback, error_callback) { var self = this; - return this._super(ids, function(result) { + return this._super(ids).then(function(result) { self.ids = _(self.ids).difference(ids); if (self._length) { self._length -= 1; @@ -898,9 +896,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ self.index = self.index <= self.ids.length - 1 ? self.index : (self.ids.length > 0 ? self.ids.length -1 : 0); } - if (callback) - callback(result); - }, error_callback); + }); }, size: function () { if (this._length !== undefined) { @@ -1113,9 +1109,9 @@ instance.web.ProxyDataSet = instance.web.DataSetSearch.extend({ return this._super.apply(this, arguments); } }, - unlink: function(ids, callback, error_callback) { + unlink: function(ids) { if (this.unlink_function) { - return this.unlink_function(ids, this._super).then(callback, error_callback); + return this.unlink_function(ids, this._super); } else { return this._super.apply(this, arguments); } diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index 5eb966aa315..c8cbc8662a5 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -359,7 +359,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, function() { + this.dataset.unlink(event_id).then(function() { self.refresh_minical(); }); } diff --git a/addons/web_view_editor/static/src/js/view_editor.js b/addons/web_view_editor/static/src/js/view_editor.js index e0e3f0f14c5..d00af6248bd 100644 --- a/addons/web_view_editor/static/src/js/view_editor.js +++ b/addons/web_view_editor/static/src/js/view_editor.js @@ -779,7 +779,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({ arch.arch = convert_to_utf; this.dataset.write(this.one_object.clicked_tr_view[0] ,{"arch":convert_to_utf}, function(r) {}); } else { - this.dataset.unlink([this.one_object.clicked_tr_view[0]],function(res) {}); + this.dataset.unlink([this.one_object.clicked_tr_view[0]]); } if(move_direct == "add_node"){ self.add_node_dialog.close();