[FIX] ir_qweb: regression of 8395f0d217

This revision corrects a regression introduced by
8395f0d217e16df18fcc6f4309fe74b0dd8d50a2:
the possibility to call
`ir.qweb.field.datetime`.`value_to_html` with
a datetime string directly, instead of calling
`ir.qweb.field.datetime`.`record_to_html`
(which call `value_to_html` as well).

opw-675427
This commit is contained in:
Denis Ledoux 2016-04-21 18:33:10 +02:00
parent 8395f0d217
commit 28e0a1771c
1 changed files with 8 additions and 7 deletions

View File

@ -712,6 +712,12 @@ 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:
@ -724,15 +730,10 @@ 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]
value = record[field_name]
return self.value_to_html(
cr, uid, value, field, options=options, context=context)
cr, uid, value, field, options=options, context=dict(context, **record.env.context))
class TextConverter(osv.AbstractModel):
_name = 'ir.qweb.field.text'