[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:
parent
8395f0d217
commit
28e0a1771c
|
@ -712,6 +712,12 @@ class DateTimeConverter(osv.AbstractModel):
|
||||||
lang = self.user_lang(cr, uid, context=context)
|
lang = self.user_lang(cr, uid, context=context)
|
||||||
locale = babel.Locale.parse(lang.code)
|
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:
|
if options and 'format' in options:
|
||||||
pattern = options['format']
|
pattern = options['format']
|
||||||
else:
|
else:
|
||||||
|
@ -724,15 +730,10 @@ class DateTimeConverter(osv.AbstractModel):
|
||||||
return babel.dates.format_datetime(value, format=pattern, locale=locale)
|
return babel.dates.format_datetime(value, format=pattern, locale=locale)
|
||||||
|
|
||||||
def record_to_html(self, cr, uid, field_name, record, options, context=None):
|
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]
|
field = field = record._fields[field_name]
|
||||||
|
value = record[field_name]
|
||||||
return self.value_to_html(
|
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):
|
class TextConverter(osv.AbstractModel):
|
||||||
_name = 'ir.qweb.field.text'
|
_name = 'ir.qweb.field.text'
|
||||||
|
|
Loading…
Reference in New Issue