From ed677bbfae8bd248441ec0a990ff96a95dc4ba3e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 14 Feb 2012 09:50:44 +0100 Subject: [PATCH] [IMP] fields.date.context_today: actually use the optional timestamp + better naming - optional datetime was not being used - parameter renamed to timestamp to better indicate that it must be a datetime, not a simple date bzr revid: odo@openerp.com-20120214085044-unpa77hork25gtif --- openerp/osv/fields.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 94b638e368a..26d06e52232 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -273,14 +273,16 @@ class date(_column): tools.DEFAULT_SERVER_DATE_FORMAT) @staticmethod - def context_today(cr, uid, today=None, context=None): + def context_today(cr, uid, timestamp=None, context=None): """Returns the current date as seen in the client's timezone in a format fit for date fields. This method may be passed as value to initialize _defaults. - :param datetime today: optional date value to use instead of - the current date""" - today = DT.datetime.now() + :param datetime timestamp: optional datetime value to use instead of + the current date and time (must be a + datetime, regular dates can't be converted + between timezones.)""" + today = timestamp or DT.datetime.now() context_today = None if context and context.get('tz'): try: