OpenERP/Odoo:fields.datetime.now()显示最近重启的日期 [英] OpenERP/Odoo: fields.datetime.now() show the date of the latest restart

查看:54
本文介绍了OpenERP/Odoo:fields.datetime.now()显示最近重启的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字段datetime.默认情况下,此字段的日期时间应为现在",即当前时间.

I have a field datetime. This field should have by default the datetime of "now", the current time.

但是,默认日期是最近一次重启的时间.

However, the default date is the time of the lastest restart.

请在下面找到我的代码:

Please find below my code:

'date_action': fields.datetime('Date current action', required=False, readonly=False, select=True),

_defaults = {
    'date_action': fields.datetime.now(),

推荐答案

您正在将 date_action 的默认值设置为 fields.datetime.now(),这是在启动odoo服务器时执行的.

You are setting the default value of date_action as the value returned by fields.datetime.now(), that is executed when odoo server is started.

您应将默认值设置为对该方法的调用:

You should set the default value as the call to the method:

'date_action': fields.datetime.now,

这篇关于OpenERP/Odoo:fields.datetime.now()显示最近重启的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆