Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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:
|Someones has an idea why? And how to solve it?|
In V8 or above, if the class definition is as per latest api, i.e (models.Model)
then use the below like syntax, no need to import any date-related files.
date_action = fields.Datetime('Date current action', required=False, readonly=False, select=True
, default=lambda self: fields.datetime.now())
For v8/v9: You have not defined the field correctly, not using a CAPITAL for Datetime:
'date_action': fields.Datetime('Date current action', required=False, readonly=False, select=True),
For v7: You are mixing the API functions.
from openerp.osv import fields, osv from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/30/16, 9:30 AM|
|Seen: 953 times|
|Last updated: 1/19/17, 5:29 AM|