I
El 19/03/2014 20:29, "Jordi Esteve" <jes...@zikzakmedia.com> va escriure:
>
> There is a way to get the default datetime value for now in Tryton?
>
> To get a default date for today there is today() method in Date class. It is overwritten in company module to take into account the timezone of the company.
>
> But I am missing a now() method to get the a default datetime value that also takes into account the timezone of the company. It will be useful to fill a default datetime field, for example. Maybe I must write an issue.
It's older codereview and need to add timezone
http://codereview.tryton.org/507002/
Arguement about this topic:
https://groups.google.com/forum/m/#!msg/tryton-dev/-XjVVeQQ3XU/0q5q_VHM5IUJ
IMHO is necessary now method when like get date today and hour now.
Example with now and timezone
Company = Pool().get('company.company')
timezone = None
if Transaction().context.get('company'):
company = Company(Transaction().context['company'])
if company.timezone and pytz:
timezone = pytz.timezone(company.timezone)
return datetime.now(timezone)
It is not. datetime.now() will return now in UTC which is always now in
any timezone.
Tryton switched for 3.2 to good practice which is to
always work/store/manipulate UTC.
So adding a Date.now() that return now with an other timezone will just
create bad practice.
It is not. datetime.now() will return now in UTC which is always now in
any timezone.I think is not true. datetime.now() return current local date and time, not UTC (1).