def session_info(self): session_info = super(Http, self).session_info() user = request.env.user if user.check_user_is_draft_seller() or user.check_user_is_seller(): user_context = request.session.get_context( ) if request.session.uid else {} mods = module_boot() qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum( addons=mods, debug=request.session.debug) lang = user_context.get("lang") translations_per_module, lang_params = request.env[ 'ir.translation'].get_translations_for_webclient(mods, lang) translation_cache = { 'lang': lang, 'lang_parameters': lang_params, 'modules': translations_per_module, 'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1, } menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus( request.session.debug), default=ustr, sort_keys=True).encode() translations_json_utf8 = json.dumps(translation_cache, sort_keys=True).encode() cache_hashes = { "load_menus": hashlib.sha1(menu_json_utf8).hexdigest(), "qweb": qweb_checksum, "translations": hashlib.sha1(translations_json_utf8).hexdigest(), } session_info.update({ "user_companies": { 'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids] }, "currencies": self.get_currencies(), "show_effect": True, "display_switch_company_menu": user.has_group('base.group_multi_company') and len(user.company_ids) > 1, "cache_hashes": cache_hashes, }) return session_info
def session_info(self): user = request.env.user version_info = odoo.service.common.exp_version() user_context = request.session.get_context() if request.session.uid else {} session_info = { "uid": request.session.uid, "is_system": user._is_system() if request.session.uid else False, "is_admin": user._is_admin() if request.session.uid else False, "user_context": request.session.get_context() if request.session.uid else {}, "db": request.session.db, "server_version": version_info.get('server_version'), "server_version_info": version_info.get('server_version_info'), "name": user.name, "username": user.login, "partner_display_name": user.partner_id.display_name, "company_id": user.company_id.id if request.session.uid else None, # YTI TODO: Remove this from the user context "partner_id": user.partner_id.id if request.session.uid and user.partner_id else None, "web.base.url": self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''), } if self.env.user.has_group('base.group_user'): # the following is only useful in the context of a webclient bootstrapping # but is still included in some other calls (e.g. '/web/session/authenticate') # to avoid access errors and unnecessary information, it is only included for users # with access to the backend ('internal'-type users) mods = module_boot() qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum(addons=mods, debug=request.session.debug) lang = user_context.get("lang") translations_per_module, lang_params = request.env['ir.translation'].get_translations_for_webclient(mods, lang) translation_cache = { 'lang': lang, 'lang_parameters': lang_params, 'modules': translations_per_module, 'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1, } menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus(request.session.debug), default=ustr, sort_keys=True).encode() translations_json_utf8 = json.dumps(translation_cache, sort_keys=True).encode() cache_hashes = { "load_menus": hashlib.sha512(menu_json_utf8).hexdigest()[:64], # sha512/256 "qweb": qweb_checksum, "translations": hashlib.sha512(translations_json_utf8).hexdigest()[:64], # sha512/256 } session_info.update({ # current_company should be default_company "user_companies": {'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids]}, "currencies": self.get_currencies(), "show_effect": True, "display_switch_company_menu": user.has_group('base.group_multi_company') and len(user.company_ids) > 1, "cache_hashes": cache_hashes, }) return session_info
def session_info(self): user = request.env.user user_context = request.session.get_context( ) if request.session.uid else {} result = super().session_info() if self.env.user.has_group('base.group_portal'): # the following is only useful in the context of a webclient bootstrapping # but is still included in some other calls (e.g. '/web/session/authenticate') # to avoid access errors and unnecessary information, it is only included for users # with access to the backend ('internal'-type users) mods = module_boot() qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum( addons=mods, debug=request.session.debug) lang = user_context.get("lang") translation_hash = request.env[ 'ir.translation'].get_web_translations_hash(mods, lang) menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus( request.session.debug), default=ustr, sort_keys=True).encode() cache_hashes = { "load_menus": hashlib.sha1(menu_json_utf8).hexdigest(), "qweb": qweb_checksum, "translations": translation_hash, } result.update({ # current_company should be default_company "user_companies": { 'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids] }, "currencies": self.get_currencies(), "show_effect": True, "display_switch_company_menu": user.has_group('base.group_multi_company') and len(user.company_ids) > 1, "cache_hashes": cache_hashes, }) return result
def session_info(self): user = request.env.user version_info = odoo.service.common.exp_version() user_context = request.session.get_context() if request.session.uid else {} mods = module_boot() qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum(addons=mods, debug=request.session.debug) lang = user_context.get("lang") translations_per_module, lang_params = request.env['ir.translation'].get_translations_for_webclient(mods, lang) translation_cache = { 'lang': lang, 'lang_parameters': lang_params, 'modules': translations_per_module, 'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1, } menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus(request.session.debug), default=ustr, sort_keys=True).encode() translations_json_utf8 = json.dumps(translation_cache, sort_keys=True).encode() return { "uid": request.session.uid, "is_system": user._is_system() if request.session.uid else False, "is_admin": user._is_admin() if request.session.uid else False, "user_context": request.session.get_context() if request.session.uid else {}, "db": request.session.db, "server_version": version_info.get('server_version'), "server_version_info": version_info.get('server_version_info'), "name": user.name, "username": user.login, "partner_display_name": user.partner_id.display_name, "company_id": user.company_id.id if request.session.uid else None, # YTI TODO: Remove this from the user context "partner_id": user.partner_id.id if request.session.uid and user.partner_id else None, # current_company should be default_company "user_companies": {'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids]}, "currencies": self.get_currencies() if request.session.uid else {}, "web.base.url": self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''), "show_effect": True, "display_switch_company_menu": user.has_group('base.group_multi_company') and len(user.company_ids) > 1, "cache_hashes": { "load_menus": hashlib.sha1(menu_json_utf8).hexdigest(), "qweb": qweb_checksum, "translations": hashlib.sha1(translations_json_utf8).hexdigest(), }, }
def session_info(self): user = request.env.user version_info = odoo.service.common.exp_version() user_context = request.session.get_context() if request.session.uid else {} mods = module_boot() files = [f[0] for f in manifest_glob('qweb', addons=','.join(mods))] _, qweb_checksum = concat_xml(files) lang = user_context.get("lang") translations_per_module, _ = request.env['ir.translation'].get_translations_for_webclient(mods, lang) menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus(request.debug), default=ustr, sort_keys=True).encode() translations_json_utf8 = json.dumps(translations_per_module, sort_keys=True).encode() return { "uid": request.session.uid, "is_system": user._is_system() if request.session.uid else False, "is_admin": user._is_admin() if request.session.uid else False, "user_context": request.session.get_context() if request.session.uid else {}, "db": request.session.db, "server_version": version_info.get('server_version'), "server_version_info": version_info.get('server_version_info'), "name": user.name, "username": user.login, "partner_display_name": user.partner_id.display_name, "company_id": user.company_id.id if request.session.uid else None, # YTI TODO: Remove this from the user context "partner_id": user.partner_id.id if request.session.uid and user.partner_id else None, # current_company should be default_company "user_companies": {'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids]}, "currencies": self.get_currencies() if request.session.uid else {}, "web.base.url": self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''), "show_effect": True, "display_switch_company_menu": user.has_group('base.group_multi_company') and len(user.company_ids) > 1, "toggle_company": user.has_group('base.group_toggle_company'), "cache_hashes": { "load_menus": hashlib.sha1(menu_json_utf8).hexdigest(), "qweb": qweb_checksum, "translations": hashlib.sha1(translations_json_utf8).hexdigest(), }, }
def get_modules_order(): if request: from odoo.addons.web.controllers.main import module_boot return json.dumps(module_boot()) return '[]'
"partner_display_name": user.partner_id.display_name, "company_id": user.company_id.id if request.session.uid else None, # YTI TODO: Remove this from the user context "partner_id": user.partner_id.id if request.session.uid and user.partner_id else None, <<<<<<< HEAD "web.base.url": self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''), ======= "web.base.url": IrConfigSudo.get_param('web.base.url', default=''), "active_ids_limit": int(IrConfigSudo.get_param('web.active_ids_limit', default='20000')), >>>>>>> f0a66d05e70e432d35dc68c9fb1e1cc6e51b40b8 } if self.env.user.has_group('base.group_user'): # the following is only useful in the context of a webclient bootstrapping # but is still included in some other calls (e.g. '/web/session/authenticate') # to avoid access errors and unnecessary information, it is only included for users # with access to the backend ('internal'-type users) mods = module_boot() qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum(addons=mods, debug=request.session.debug) lang = user_context.get("lang") translation_hash = request.env['ir.translation'].get_web_translations_hash(mods, lang) menu_json_utf8 = json.dumps(request.env['ir.ui.menu'].load_menus(request.session.debug), default=ustr, sort_keys=True).encode() cache_hashes = { <<<<<<< HEAD "load_menus": hashlib.sha1(menu_json_utf8).hexdigest(), ======= "load_menus": hashlib.sha512(menu_json_utf8).hexdigest()[:64], # sha512/256 >>>>>>> f0a66d05e70e432d35dc68c9fb1e1cc6e51b40b8 "qweb": qweb_checksum, "translations": translation_hash, } session_info.update({ # current_company should be default_company