diff options
| author | Frederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com> | 2014-08-21 15:36:56 +0200 |
|---|---|---|
| committer | Frederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com> | 2014-08-26 12:21:04 +0200 |
| commit | ea7b440dc84fc63fe02dd99ef36bfb186f5f285c (patch) | |
| tree | 76b7cd94917fd2d441dab400a42300cb3b437c4e /addons/web/static/src/js/data.js | |
| parent | f57787e07ee48268015cd088bfc3dafef7001558 (diff) | |
[IMP] web: allow rpc options to be passed to Model.query() calls
Diffstat (limited to 'addons/web/static/src/js/data.js')
| -rw-r--r-- | addons/web/static/src/js/data.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index f580d282516..c22faaae9bd 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -73,8 +73,9 @@ instance.web.Query = instance.web.Class.extend({ } return q; }, - _execute: function () { + _execute: function (options) { var self = this; + options = options || {}; return instance.session.rpc('/web/dataset/search_read', { model: this._model.name, fields: this._fields || false, @@ -85,7 +86,7 @@ instance.web.Query = instance.web.Class.extend({ offset: this._offset, limit: this._limit, sort: instance.web.serialize_sort(this._order_by) - }).then(function (results) { + }, options).then(function (results) { self._count = results.length; return results.records; }, null); @@ -93,11 +94,12 @@ instance.web.Query = instance.web.Class.extend({ /** * Fetches the first record matching the query, or null * + * @param {Object} [options] additional options for the rpc() method * @returns {jQuery.Deferred<Object|null>} */ - first: function () { + first: function (options) { var self = this; - return this.clone({limit: 1})._execute().then(function (records) { + return this.clone({limit: 1})._execute(options).then(function (records) { delete self._count; if (records.length) { return records[0]; } return null; @@ -106,10 +108,11 @@ instance.web.Query = instance.web.Class.extend({ /** * Fetches all records matching the query * + * @param {Object} [options] additional options for the rpc() method * @returns {jQuery.Deferred<Array<>>} */ - all: function () { - return this._execute(); + all: function (options) { + return this._execute(options); }, /** * Fetches the number of records matching the query in the database |
