Reputation: 57
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(),
Upvotes: 1
Views: 3493
Reputation: 329
try to use lambda
For example in Odoo 8 :
date_action = fields.Datetime(string="Date current action", default=lambda *a: datetime.now())
Upvotes: 1
Reputation: 446
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,
Upvotes: 5