summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/session.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-04-17 17:08:17 +0200
committerChristophe Simonis <chs@odoo.com>2015-04-17 17:08:17 +0200
commit107b589a11dfa6a81d97d081d8b2bcb60f05b4e9 (patch)
tree7ece7add3b1ecf71be6e110827554751c4fc93a8 /addons/web/static/src/js/framework/session.js
parenta9471c43b952a1b3ecd92dcbcc0719723336acf1 (diff)
[FIX] *: correct previous forward port
Due to files renaming, some patched should be applied manually to the correct files. Forgot to `git add` these files when committing the forward port...
Diffstat (limited to 'addons/web/static/src/js/framework/session.js')
-rw-r--r--addons/web/static/src/js/framework/session.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/session.js b/addons/web/static/src/js/framework/session.js
index 8b084f640fd..38fa3465808 100644
--- a/addons/web/static/src/js/framework/session.js
+++ b/addons/web/static/src/js/framework/session.js
@@ -4,6 +4,7 @@ odoo.define('web.Session', function (require) {
var ajax = require('web.ajax');
var core = require('web.core');
var utils = require('web.utils');
+var Model = require('web.Model');
var _t = core._t;
var qweb = core.qweb;
@@ -41,6 +42,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
// TODO: session store in cookie should be optional
this.qweb_mutex = new utils.Mutex();
this.currencies = {};
+ this._groups_def = {};
},
setup: function(origin, options) {
// must be able to customize server
@@ -129,6 +131,17 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
$.bbq.removeState();
return this.rpc("/web/session/destroy", {});
},
+ user_has_group: function(group) {
+ if (!this.uid) {
+ return $.when().resolve(false);
+ }
+ var def = this._groups_def[group];
+ if (!def) {
+ var Users = new Model('res.users');
+ def = this._groups_def[group] = Users.call('has_group', [group]);
+ }
+ return def;
+ },
get_cookie: function (name) {
if (!this.name) { return null; }
var nameEQ = this.name + '|' + name + '=';