跳至内容
菜单
此问题已终结
4 回复
7873 查看

On our Windows Server Odoo instance I use date.today() to set the default of the date to, well, today. However, this morning we realized that the date was off, but the date of the server was correct. I restarted the server and the date in Windows did NOT change, however, the Odoo module default date did. What gives?

The line of code is as follow (no errors though)
'order_date': fields.date(string='Date', default=date.today())

形象
丢弃
最佳答案

The solution is to not call the function:

my_field = fields.Date(default=fields.Date.today)
形象
丢弃
最佳答案

date.today() returns a value, so the python interpreter thinks that you want set a constant to default value.
Use lambda function to avoid this:

default =  lambda self: fields.Date.today()

形象
丢弃
编写者 最佳答案

Even on a linux machine this happens. Maybe it's the version I am using, but updating the custom app date.today() requires a restart everytime.

形象
丢弃
最佳答案

Check your Timezone configuration on users

形象
丢弃
编写者

That wasn't it. Timezones via Odoo and Windows machine all match. Now the date is staying the same as my restart date. Maybe it has something to do with the module being instantiated on that date.

相关帖文 回复 查看 活动
8
5月 23
61529
4
2月 23
71864
1
5月 16
3912
python in v9 已解决
1
11月 15
6002
2
4月 23
23414