camptocamp/odoo-cloud-platform

[12.0] session_redis: Odoo server error when accessing a shared record

andrp92 opened this issue · 6 comments

Hello,
I’m getting internal server error after using this module to store my odoo sessions in Redis. When sharing a document for public access (https://mydomain.com/my/orders/24?access_token=982cfbfb-0b4e-4929-97c3-2f428ea25731&). If the user is logged in, the URL works fine, otherwise I get the following error:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/werkzeug/serving.py", line 303, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.7/site-packages/werkzeug/serving.py", line 291, in execute
application_iter = app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/odoo/service/server.py", line 434, in app
return self.app(e, s)
File "/usr/local/lib/python3.7/site-packages/odoo/service/wsgi_server.py", line 142, in application
return application_unproxied(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/odoo/service/wsgi_server.py", line 117, in application_unproxied
result = odoo.http.root(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/odoo/http.py", line 1320, in call
return self.dispatch(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/odoo/http.py", line 1293, in call
return self.app(environ, start_wrapped)
File "/usr/local/lib/python3.7/site-packages/werkzeug/middleware/shared_data.py", line 220, in call
return self.app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/odoo/http.py", line 1492, in dispatch
response = self.get_response(httprequest, result, explicit_session)
File "/usr/local/lib/python3.7/site-packages/odoo/http.py", line 1426, in get_response
self.session_store.save(httprequest.session)
File "/var/lib/odoo/extra-addons/camptocamp/odoo-cloud-platform/session_redis/session.py", line 60, in save
data = json.dumps(dict(session)).encode('utf-8')
File "/usr/local/lib/python3.7/json/init.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/local/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/lib/python3.7/site-packages/odoo/tools/func.py", line 251, in default
return json_encoder_default(self, o)
File "/usr/local/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type date is not JSON serializable 84 0.087 0.072

Hi,

It comes from a module that put a datetime object in the session, and it's not serializable to Json. IIRC there was an occurrence in an official add-on, but has been fixed (to check).

Here is the correction odoo/odoo#41323

@Tonow-c2c can you check the comments on your PR?

@guewen @Tonow-c2c Odoo is only waiting for the CLA sign to be present on the branch so they can merge the PR. Can you please help? Thanks in advance.

There are new comments on the PR odoo/odoo#41323 cc: @Tonow-c2c @guewen

This issue can be closed cc: @andrp92

Thank you @Tonow-c2c !!

Cool, thanks all!