From 8395f0d217e16df18fcc6f4309fe74b0dd8d50a2 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 21 Apr 2016 17:46:09 +0200 Subject: [PATCH] [FIX] website_event: event dates within event timezone The dates of an event on the website was always within the user timezone. If not signed in, it was within the public user timezone (which is quite not user-friendly to change) For this purpose, we weed get the context from the record (the context used when using `record.with_context`), and therefore the QWeb field `ir.qweb.field.datetime` is slightly altered, to use the context from the record. opw-675427 --- addons/website_event/views/website_event.xml | 10 +++++----- openerp/addons/base/ir/ir_qweb.py | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml index 74846554ff3..6ac4dd86cf9 100644 --- a/addons/website_event/views/website_event.xml +++ b/addons/website_event/views/website_event.xml @@ -66,7 +66,7 @@
- to + to
to - + to +


- To + From
+ To

diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index dd043a32a0c..a26ba5fca6b 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -712,12 +712,6 @@ class DateTimeConverter(osv.AbstractModel): lang = self.user_lang(cr, uid, context=context) locale = babel.Locale.parse(lang.code) - if isinstance(value, basestring): - value = datetime.datetime.strptime( - value, openerp.tools.DEFAULT_SERVER_DATETIME_FORMAT) - value = fields.datetime.context_timestamp( - cr, uid, timestamp=value, context=context) - if options and 'format' in options: pattern = options['format'] else: @@ -729,6 +723,17 @@ class DateTimeConverter(osv.AbstractModel): return babel.dates.format_datetime(value, format=pattern, locale=locale) + def record_to_html(self, cr, uid, field_name, record, options, context=None): + value = record[field_name] + if isinstance(value, basestring): + value = datetime.datetime.strptime( + value, openerp.tools.DEFAULT_SERVER_DATETIME_FORMAT) + value = fields.datetime.context_timestamp( + cr, uid, timestamp=value, context=record.env.context) + field = field = record._fields[field_name] + return self.value_to_html( + cr, uid, value, field, options=options, context=context) + class TextConverter(osv.AbstractModel): _name = 'ir.qweb.field.text' _inherit = 'ir.qweb.field'