Files
gzth/sun_badge_menu/views/webclient_templates.xml
T
2025-09-02 21:55:12 +08:00

30 lines
1.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="webclient_bootstrap" inherit_id="web.webclient_bootstrap">
<xpath expr="//script" position="replace">
<script type="text/javascript">
// Block to avoid leaking variables in the script scope
{
odoo.__session_info__ = <t t-out="json.dumps(session_info)"/>;
const { user_context, cache_hashes } = odoo.__session_info__;
const lang = new URLSearchParams(document.location.search).get("lang");
let load_menus= new Date().getTime().toString();
let menuURL = `/web/webclient/load_menus/${load_menus}`;
if (lang) {
user_context.lang = lang;
menuURL += `?lang=${lang}`
}
odoo.reloadMenus = () => fetch(menuURL).then(res => res.json());
odoo.loadMenusPromise = odoo.reloadMenus();
// Prefetch translations to speedup webclient. This is done in JS because link rel="prefetch"
// is not yet supported on safari.
fetch(`/web/webclient/translations/${cache_hashes.translations}?lang=${user_context.lang}`);
}
</script>
</xpath>
</template>
</data>
</odoo>