From f0c294e58423365eb5e7d860d85f81365722a43a Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 10 Jan 2012 15:35:13 +0100 Subject: [PATCH] [ADD] Add options arguments to Dataset#read_index in order to provide custom contexts bzr revid: fme@openerp.com-20120110143513-00p14goadekz0y4z --- addons/web/static/src/js/data.js | 5 +++-- addons/web_dashboard/static/src/js/dashboard.js | 2 +- addons/web_diagram/static/src/js/diagram.js | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index c24325a9327..3b444dffc78 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -322,16 +322,17 @@ openerp.web.DataSet = openerp.web.Widget.extend( /** @lends openerp.web.DataSet * Reads the current dataset record (from its index) * * @params {Array} [fields] fields to read and return, by default all fields are returned + * @param {Object} [options.context] context data to add to the request payload, on top of the DataSet's own context * @params {Function} callback function called with read_index result * @returns {$.Deferred} */ - read_index: function (fields, callback) { + read_index: function (fields, options, callback) { var def = $.Deferred().then(callback); if (_.isEmpty(this.ids)) { def.reject(); } else { fields = fields || false; - this.read_ids([this.ids[this.index]], fields).then(function(records) { + this.read_ids([this.ids[this.index]], fields, options).then(function(records) { def.resolve(records[0]); }, function() { def.reject.apply(def, arguments); diff --git a/addons/web_dashboard/static/src/js/dashboard.js b/addons/web_dashboard/static/src/js/dashboard.js index 28ea12796d2..2ac6c68cff5 100644 --- a/addons/web_dashboard/static/src/js/dashboard.js +++ b/addons/web_dashboard/static/src/js/dashboard.js @@ -290,7 +290,7 @@ openerp.web_dashboard.ConfigOverview = openerp.web.View.extend({ start: function () { this._super(); var self = this; - return this.user.read_index(['groups_id']).pipe(function (record) { + return this.user.read_index(['groups_id']).pipe(function(record) { var todos_filter = [ ['type', '!=', 'automatic'], '|', ['groups_id', '=', false], diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index f88a7fd73ee..ddc88d920de 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -219,7 +219,7 @@ openerp.web.DiagramView = openerp.web.View.extend({ this.context || this.dataset.context ); pop.on_select_elements.add_last(function(element_ids) { - self.dataset.read_index(_.keys(self.fields_view.fields), self.on_diagram_loaded); + self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_diagram_loaded); }); } else { pop = new openerp.web.form.FormOpenPopup(this); @@ -232,7 +232,7 @@ openerp.web.DiagramView = openerp.web.View.extend({ } ); pop.on_write.add(function() { - self.dataset.read_index(_.keys(self.fields_view.fields), self.on_diagram_loaded); + self.dataset.read_index(_.keys(self.fields_view.fields)).pipe(self.on_diagram_loaded); }); } @@ -292,7 +292,7 @@ openerp.web.DiagramView = openerp.web.View.extend({ this.dataset.index = this.dataset.ids.length - 1; break; } - this.dataset.read_index(_.keys(this.fields_view.fields), this.on_diagram_loaded); + this.dataset.read_index(_.keys(this.fields_view.fields)).pipe(this.on_diagram_loaded); this.do_update_pager(); },