mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 22:12:03 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -1,27 +1,28 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import odoo
|
||||
from odoo import models
|
||||
from odoo.http import request
|
||||
from odoo.addons.mail.tools.discuss import Store
|
||||
|
||||
|
||||
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
|
||||
"""Override to add the current user data (partner or guest) if applicable."""
|
||||
result = super().session_info()
|
||||
store = Store()
|
||||
ResUsers = self.env["res.users"]
|
||||
if cids := request.cookies.get("cids", False):
|
||||
allowed_company_ids = []
|
||||
for company_id in [int(cid) for cid in cids.split("-")]:
|
||||
if company_id in self.env.user.company_ids.ids:
|
||||
allowed_company_ids.append(company_id)
|
||||
ResUsers = self.with_context(allowed_company_ids=allowed_company_ids).env["res.users"]
|
||||
ResUsers._init_store_data(store)
|
||||
result["storeData"] = store.get_result()
|
||||
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,
|
||||
})
|
||||
result["user_context"] = user_context
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue