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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
4
Replies
32264
Tampilan
ok thx, it works, I do this :
_defaults= {
'record_date': fields.date.context_today,
}
import time
admission_date = fields.Date('Admission Date', default=date.today())
In this code is used to generate default current date
You have to add this:
import time
and you can add this to _defaults
_defaults= {
'date_field': lambda *a: time.strftime('%Y-%m-%d'),
}
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
0
Jan 20
|
604 | ||
|
1
Nov 22
|
3195 | ||
How can I calculate difference between two dates ?
Diselesaikan
|
|
3
Nov 21
|
25815 | |
how to customize year range in date field?
Diselesaikan
|
|
1
Agu 15
|
5348 | |
Year only needed - how to implement?
Diselesaikan
|
|
2
Mar 15
|
5277 |
from_date = fields.Date(string="From Date" ,default=datetime.now())