Odoo Help

Welcome!

This community 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.

1

Put automatically the date of today in a field

By
MALLE SOULEYMANE
on 7/31/13, 12:50 PM 4,961 views

Hi. I create a field date in my module class file, and I want to put automatically the day of today (for example) as default date. Help me please. thx

4
MALLE SOULEYMANE
On 8/1/13, 6:42 AM

ok thx, it works, I do this :

_defaults= {
    'record_date': fields.date.context_today,
}
1
kirubanidhi
On 6/23/16, 9:32 AM

import time

admission_date = fields.Date('Admission Date', default=date.today())


In this code is used to generate default current date

1

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 7/31/13, 1:04 PM

You have to add this:

import time

and you can add this to _defaults

    _defaults= {
    'date_field': lambda *a: time.strftime('%Y-%m-%d'),
}

Your Answer

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/31/13, 12:50 PM
Seen: 4961 times
Last updated: 6/23/16, 9:32 AM