diff --git a/src/rpc.js b/src/rpc.js index d9c2ab586a..75247eb2f3 100644 --- a/src/rpc.js +++ b/src/rpc.js @@ -8,12 +8,14 @@ if (!session) { session = new Sao.Session(); } + var params = jQuery.extend([], args.params); + params.push(jQuery.extend({}, session.context, params.pop())); var ajax_prm = jQuery.ajax({ 'contentType': 'application/json', 'data': JSON.stringify(Sao.rpc.prepareObject({ 'method': args.method, - 'params': [session.user_id, session.session].concat(args.params) + 'params': [session.user_id, session.session].concat(params) })), 'dataType': 'json', 'url': '/' + (session.database || ''), diff --git a/src/session.js b/src/session.js index 47b7a45a56..c901d6cde5 100644 --- a/src/session.js +++ b/src/session.js @@ -9,7 +9,7 @@ this.login = login; this.user_id = null; this.session = null; - this.context = {}; // TODO fill + this.context = {}; if (!Sao.Session.current_session) { Sao.Session.current_session = this; } @@ -65,6 +65,16 @@ this.user_id = null; this.session = null; return prm; + }, + reload_context: function() { + var args = { + 'method': 'model.res.user.get_preferences', + 'params': [true, {}] + }; + var prm = Sao.rpc(args, this); + return prm.then(function(context) { + this.context = context; + }.bind(this)); } });