Solving Odoo ERP Default Date time Issues

Christopher Maduka
1 min readJan 15, 2021

Over my 7 years experience working on odoo ERP, I have not encountered an issue with adding default datetime fields feature in a model. Perhaps, this might be a bug or somewhat issues related to server configuration.

First, my client called to notify me about the sudden misbehavior of date time functionality while creating records.

After few minutes of debugging, i discovered that while using the odoo fields.Datetime.now feature as default option, this issue occurs. Odoo haven’t given an explanation to this.

Solutions:
1. Simply restart the server. The reason for this is that the fields.Datetime.now feature makes use of the last restarted date.

2. Write a function for it and then call it in the field, e.g
date = fields.Datetime(string=”Date”, default=lambda self:self.yourpythonfunction())

3. Use this method:
date = fields.Datetime(string=”Date”, default = datetime.datetime.now())

Conclusion:
Solution 1 is a better option except you want to do data migration on already existing records.

--

--

Christopher Maduka

A software Developer, Enterprise Resource Planning enthusiast, 3D animator and VFX developer