I´m trying to set default date as the actual date at a specific hour, like today at 09:00
_defaults = {
'date_start': VALUE,
}
i´ve tried:
fields.date.context_today + datetime.timedelta(hours=9)
but throws an error because fields.date.context_today is a function.
If i only put: fields.date.context_today, displays today´s date at 00:00 but y want 09:00. How can i do this?
the field is datetime.
_defaults={ 'date_start': lambda *a: time.strftime('%Y-%m-%d-00-00-00'), } will give you date in following format :2013-11-06 11:11:11 If you want other format you can change that
Thanks, that works, but it converts the time depending on the timezone. I had to create a function to convert set the time to the hour I wanted
I think you will get exact time which is depending on tz so you need to use tz which present in context. I am not sure about this but hope it will help you :)