summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-09-07 07:51:09 +0000
committerAaron Bohy <aab@odoo.com>2020-09-07 07:51:09 +0000
commit0a43d8040f0c5ec8e9728b2e9da8c7d46d7292bb (patch)
tree417c058c92f24db3ed4f93014e899c11dc70420d /addons
parentfd3bc2def4e0c5e9f6e91dda24787230a75c00cb (diff)
[IMP] web: tz cookie: test if already set
This commit adds a test to save the effort of re-setting the tz cookie when it is already set. We also merge the tz cookie script with the one defining session_info. Commit motivated by discussion on PR #55726 closes odoo/odoo#57147 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/web/views/webclient_templates.xml10
1 files changed, 4 insertions, 6 deletions
diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml
index 6cdde6286b6..47ee5cea4e5 100644
--- a/addons/web/views/webclient_templates.xml
+++ b/addons/web/views/webclient_templates.xml
@@ -466,12 +466,6 @@
<xpath expr="//head/meta[last()]" position="after">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
</xpath>
- <xpath expr="//head" position="inside">
- <script type="text/javascript">
- const userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone;
- document.cookie = `tz=${userTZ}; path=/`;
- </script>
- </xpath>
<xpath expr="//head/link[last()]" position="after">
<t t-call-assets="web.assets_common" t-js="false"/>
<t t-call-assets="web.assets_frontend" t-js="false"/>
@@ -479,6 +473,10 @@
<xpath expr="//head/script" position="after">
<script type="text/javascript">
odoo.session_info = <t t-raw="json.dumps(request.env['ir.http'].get_frontend_session_info())"/>;
+ if (!/(^|;\s)tz=/.test(document.cookie)) {
+ const userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone;
+ document.cookie = `tz=${userTZ}; path=/`;
+ }
</script>
<t t-call-assets="web.assets_common_minimal_js" t-css="false" defer_load="True"/>
<t t-call-assets="web.assets_frontend_minimal_js" t-css="false" defer_load="True"/>