summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/data.js
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2012-11-12 14:55:13 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2012-11-12 14:55:13 +0530
commitd8034fa4f4afe2fdfc81194167ededa4a4ee27a6 (patch)
treec09c9449b7cb83f4fc4739caad611529177474bb /addons/web/static/src/js/data.js
parent47e028f6c94c82e50cac026a6a9e72df211fa8c9 (diff)
parent0074bc4b3d8b1fc9d80f7a76f8f5412818de4e7c (diff)
[MERGE]
bzr revid: hmo@tinyerp.com-20121112092513-ngonx9bv68uw2gb5
Diffstat (limited to 'addons/web/static/src/js/data.js')
-rw-r--r--addons/web/static/src/js/data.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index 63c90f53758..dcdeb749672 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 || {};
@@ -358,17 +358,16 @@ instance.web.Model = instance.web.Class.extend({
},
});
-instance.web.DataSet = instance.web.CallbackEnabled.extend({
+instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, {
/**
* Collection of OpenERP records, used to share records and the current selection between views.
*
* @constructs instance.web.DataSet
- * @extends instance.web.CallbackEnabled
*
* @param {String} model the OpenERP model this dataset will manage
*/
init: function(parent, model, context) {
- this._super(parent);
+ instance.web.PropertiesMixin.init.call(this);
this.model = model;
this.context = context || {};
this.index = null;
@@ -443,7 +442,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 +455,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 +492,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
*/
write: function (id, data, options) {
options = options || {};
- return this._model.call('write', [[id], data], {context: this.get_context(options.context)}).then(this.trigger('dataset_changed', id, data, options));
+ return this._model.call('write', [[id], data], {context: this.get_context(options.context)}).done(this.trigger('dataset_changed', id, data, options));
},
/**
* Deletes an existing record from the database
@@ -501,7 +500,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.get_context()}).then(this.trigger('dataset_changed', ids));
+ return this._model.call('unlink', [ids], {context: this.get_context()}).done(this.trigger('dataset_changed', ids));
},
/**
* Calls an arbitrary RPC method
@@ -607,7 +606,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({
model: this.model,
ids: ids,
context: this.get_context(options.context),
- }).pipe(function (results) {
+ }).then(function (results) {
return results;
});
},
@@ -682,9 +681,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 +692,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 +721,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 +773,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 +835,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 +990,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);
});