From 27d8cb843b0a1d99f5e174b37e30149a56103f04 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 5 Jan 2015 12:44:59 +0100 Subject: [PATCH] [FIX] fields: apply user timezone in display name for models using a datetime as name For models using a datetime field as name (hr.attendance for instance), the user timezone wasn't applied in the display name. Therefore, in the breadcrumb, the datetime was different than in the form if the user had another timezone than UTC. --- openerp/osv/fields.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 9ee0c8da506..23afb1663c3 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -367,6 +367,11 @@ class datetime(_column): exc_info=True) return utc_timestamp + @classmethod + def _as_display_name(cls, field, cr, uid, obj, value, context=None): + value = datetime.context_timestamp(cr, uid, DT.datetime.strptime(value, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) + return tools.ustr(value.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)) + class binary(_column): _type = 'binary' _symbol_c = '%s'