summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-11-28 17:03:44 +0100
committerAntony Lesuisse <al@openerp.com>2012-11-28 17:03:44 +0100
commita34f0ef51cd1d0c68f650d59180cc63001cb3b9a (patch)
tree8ea986d1a3a7c5972a47fec12379f3045b7dfe6f /addons/web/static/src
parent299d98ac6ec0e36f4972d4413325148e8bb572fc (diff)
parent04ee6498553a34e9ecf691bbe9cd367d2980d1b5 (diff)
[MERGE] trunk-timezone-notification-fme
if res.users and browser timezone offset differs we display a warning. openerp-web relies on the browser for datetime manipulations so we need both to be in sync. bzr revid: al@openerp.com-20121128160344-1iae73w47ocot9ib
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js32
-rw-r--r--addons/web/static/src/xml/base.xml14
2 files changed, 42 insertions, 4 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 1bca6bf94cd..940bf800851 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -24,7 +24,7 @@ instance.web.Notification = instance.web.Widget.extend({
if (sticky) {
opts.expires = false;
}
- this.$el.notify('create', {
+ return this.$el.notify('create', {
title: title,
text: text
}, opts);
@@ -35,7 +35,7 @@ instance.web.Notification = instance.web.Widget.extend({
if (sticky) {
opts.expires = false;
}
- this.$el.notify('create', 'oe_notification_alert', {
+ return this.$el.notify('create', 'oe_notification_alert', {
title: title,
text: text
}, opts);
@@ -1163,6 +1163,30 @@ instance.web.WebClient = instance.web.Client.extend({
self.user_menu.do_update();
self.bind_hashchange();
self.set_title();
+ self.check_timezone();
+ },
+ check_timezone: function() {
+ var self = this;
+ var user_offset = instance.session.user_context.tz_offset;
+ var offset = -(new Date().getTimezoneOffset());
+ // _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually
+ var browser_offset = (offset < 0) ? "-" : "+";
+ browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60));
+ browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60));
+ if (browser_offset !== user_offset) {
+ var notification = this.do_warn(_t("Timezone"), QWeb.render('WebClient.timezone_notification', {
+ user_timezone: instance.session.user_context.tz || 'UTC',
+ user_offset: user_offset,
+ browser_offset: browser_offset,
+ }), true);
+ notification.element.find('.oe_webclient_timezone_notification').on('click', function() {
+ notification.close();
+ }).find('a').on('click', function() {
+ notification.close();
+ self.user_menu.on_menu_settings();
+ return false;
+ });
+ }
},
destroy_content: function() {
_.each(_.clone(this.getChildren()), function(el) {
@@ -1179,11 +1203,11 @@ instance.web.WebClient = instance.web.Client.extend({
},
do_notify: function() {
var n = this.notification;
- n.notify.apply(n, arguments);
+ return n.notify.apply(n, arguments);
},
do_warn: function() {
var n = this.notification;
- n.warn.apply(n, arguments);
+ return n.warn.apply(n, arguments);
},
on_logout: function() {
var self = this;
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 9384ee7ebe8..9aa36595cba 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -448,6 +448,20 @@
</table>
</div>
</t>
+<t t-name="WebClient.timezone_notification">
+ <div class="oe_webclient_timezone_notification">
+ <p>Your user's preference timezone does not match your browser timezone:</p>
+
+ <dl>
+ <dt>User's timezone</dt>
+ <dd><t t-esc="user_timezone"/> (<t t-esc="user_offset"/>)</dd>
+ <dt>Browser's timezone</dt>
+ <dd><t t-esc="browser_offset"/></dd>
+ </dl>
+
+ <p><a href="#">Click here to change your user's timezone.</a></p>
+ </div>
+</t>
<t t-name="EmbedClient">
<div class="openerp">