diff --git a/session_redis/__init__.py b/session_redis/__init__.py index af491fc..d3b5bfe 100644 --- a/session_redis/__init__.py +++ b/session_redis/__init__.py @@ -2,3 +2,4 @@ from . import http from . import session +from . import models diff --git a/session_redis/models/__init__.py b/session_redis/models/__init__.py new file mode 100644 index 0000000..f9b61db --- /dev/null +++ b/session_redis/models/__init__.py @@ -0,0 +1 @@ +from . import user diff --git a/session_redis/models/user.py b/session_redis/models/user.py new file mode 100644 index 0000000..e652fd7 --- /dev/null +++ b/session_redis/models/user.py @@ -0,0 +1,19 @@ +from openerp import models, tools + + +class User(models.Model): + _inherit = 'res.users' + + @tools.ormcache('sid') + def _compute_session_token(self, sid): + """Make sure to return an unicode string. + + Odoo creates a session token using hexdigest Session which is str + but with redis we set the token from a dictionary of values passing + it in json format. When dumping values from json, we always get unicode + thus both are incompatible. + + The shortest path is to fix the output of the computed session by Odoo. + + """ + return unicode(super(User, self)._compute_session_token(sid))