Files
odoo_source/addons/mail/models/ir_http.py
T
Sébastien Theys 6dacefd50a [FIX] mail: standardize way to get guest from context
Backport of `_get_guest_from_context`.

Prevent crash when unexpected (not recordset) values are in the context.

Ensure the mere existence of a value (example integer) does not lead to
executing flows where an actual guest is expected.

task-2819597

closes odoo/odoo#127831

X-original-commit: 3d1890e88b99f059377d8b227b56d77798157397
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-07-10 15:33:06 +02:00

28 lines
992 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo
from odoo import models
from odoo.http import request
class IrHttp(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
user = self.env.user
result = super(IrHttp, self).session_info()
if self.env.user._is_internal():
result['notification_type'] = user.notification_type
guest = self.env['mail.guest']._get_guest_from_context()
if not request.session.uid and guest:
user_context = {'lang': guest.lang}
mods = odoo.conf.server_wide_modules or []
lang = user_context.get("lang")
translation_hash = self.env['ir.http'].sudo().get_web_translations_hash(mods, lang)
result['cache_hashes']['translations'] = translation_hash
result.update({
'name': guest.name,
'user_context': user_context,
})
return result