From ea7b440dc84fc63fe02dd99ef36bfb186f5f285c Mon Sep 17 00:00:00 2001 From: Frederic van der Essen Date: Thu, 21 Aug 2014 15:36:56 +0200 Subject: [PATCH] [IMP] web: allow rpc options to be passed to Model.query() calls --- addons/web/static/src/js/data.js | 15 +++++++++------ 1 file 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} */ - 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>} */ - all: function () { - return this._execute(); + all: function (options) { + return this._execute(options); }, /** * Fetches the number of records matching the query in the database