[IMP] callback2deferred part1 dataset.unlink

bzr revid: al@openerp.com-20120927234513-3aohele9gcoxkha4
This commit is contained in:
Antony Lesuisse 2012-09-28 01:45:13 +02:00
parent 2f1948389e
commit a55cc6072a
3 changed files with 8 additions and 12 deletions

View File

@ -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);
}

View File

@ -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();
});
}

View File

@ -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();