summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2016-05-25 12:18:48 +0200
committerGéry Debongnie <ged@odoo.com>2016-05-30 09:23:07 +0200
commit9c68bc74827864a3c6c21be8ead1b2ed3d122d73 (patch)
treee9dec0618783fbce6d12e89369fa064c63dc886b /addons/web/static/src/js/framework
parent2a8a17024d2b46f3f8837a8672334a7dff3abd1b (diff)
[REF] point_of_sale,web(site): move session info into page source
This commit introduces a mechanism to add information into the session from a different module, without having to fetch it manually with a rpc. This is intended to be used with small pieces of info required at the start of the web client, such as currency informations. To add information to the session, one can simply inherit from ir.http and modify the session_info method.
Diffstat (limited to 'addons/web/static/src/js/framework')
-rw-r--r--addons/web/static/src/js/framework/core.js5
-rw-r--r--addons/web/static/src/js/framework/session.js11
2 files changed, 9 insertions, 7 deletions
diff --git a/addons/web/static/src/js/framework/core.js b/addons/web/static/src/js/framework/core.js
index f9ab78f1c8e..1c8b55ee377 100644
--- a/addons/web/static/src/js/framework/core.js
+++ b/addons/web/static/src/js/framework/core.js
@@ -91,6 +91,8 @@ _.extend(qweb.default_dict, {
'moment': function(date) { return new moment(date); },
});
+qweb.default_dict.csrf_token = odoo.csrf_token;
+
qweb.preprocess_node = function() {
// Note that 'this' is the Qweb Node
switch (this.node.nodeType) {
@@ -187,7 +189,8 @@ return {
search_filters_registry: new Registry(),
search_widgets_registry: new Registry(),
view_registry: new Registry(),
-};
+ csrf_token: odoo.csrf_token,
+};
});
diff --git a/addons/web/static/src/js/framework/session.js b/addons/web/static/src/js/framework/session.js
index d848fd4c511..d882128c67f 100644
--- a/addons/web/static/src/js/framework/session.js
+++ b/addons/web/static/src/js/framework/session.js
@@ -136,7 +136,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
},
user_has_group: function(group) {
if (!this.uid) {
- return $.when().resolve(false);
+ return $.when(false);
}
var def = this._groups_def[group];
if (!def) {
@@ -293,11 +293,10 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
* @returns {$.Deferred} deferred indicating the session is done reloading
*/
session_reload: function () {
- var self = this;
- return self.rpc("/web/session/get_session_info", {}).then(function(result) {
- delete result.session_id;
- _.extend(self, result);
- });
+ var result = _.extend({}, window.odoo.session_info);
+ delete result.session_id;
+ _.extend(this, result);
+ return $.when();
},
check_session_id: function() {
var self = this;