summaryrefslogtreecommitdiff
path: root/addons/base/static/src/js/data.js
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2011-06-22 16:51:53 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2011-06-22 16:51:53 +0200
commit9d32bef7c7fd2d9b654ae835b66109bb120dda7b (patch)
tree20af5c3bef85a121fd5d532e3e669bbc73a1dce9 /addons/base/static/src/js/data.js
parent46abe6600a40c0088cc83928e71167b9e816032e (diff)
parent58291d4ab605ff5b9882bb84de537ce1ff6e73cf (diff)
[merge]
bzr revid: nicolas.vanhoren@openerp.com-20110622145153-1j0ntku8qndpij1o
Diffstat (limited to 'addons/base/static/src/js/data.js')
-rw-r--r--addons/base/static/src/js/data.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js
index 736c31c1f7b..47e6d4fed3d 100644
--- a/addons/base/static/src/js/data.js
+++ b/addons/base/static/src/js/data.js
@@ -310,9 +310,10 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
context: this.context
}, callback);
},
- unlink: function(ids) {
- // to implement in children
- this.notification.notify("Unlink", ids);
+ unlink: function(ids, callback, error_callback) {
+ var self = this;
+ return this.call_and_eval("unlink", [ids, this.context], null, 1,
+ callback, error_callback);
},
call: function (method, args, callback, error_callback) {
return this.rpc('/base/dataset/call', {
@@ -362,9 +363,12 @@ openerp.base.DataSetStatic = openerp.base.DataSet.extend({
set_ids: function (ids) {
this.ids = ids;
this.count = this.ids.length;
+ this.index = this.index <= this.count - 1 ?
+ this.index : (this.count > 0 ? this.count - 1 : 0);
},
unlink: function(ids) {
this.on_unlink(ids);
+ return $.Deferred().resolve({result: true});
},
on_unlink: function(ids) {
this.set_ids(_.without.apply(null, [this.ids].concat(ids)));
@@ -438,6 +442,17 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({
this._sort.unshift((reverse ? '-' : '') + field);
return undefined;
+ },
+ unlink: function(ids, callback, error_callback) {
+ var self = this;
+ return this._super(ids, function(result) {
+ self.ids = _.without.apply(_, [self.ids].concat(ids));
+ self.count = self.ids.length;
+ self.index = self.index <= self.count - 1 ?
+ self.index : (self.count > 0 ? self.count -1 : 0);
+ if (callback)
+ callback(result);
+ }, error_callback);
}
});