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
To pytanie dostało ostrzeżenie
4
Odpowiedzi
35227
Widoki
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'),
}
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się| Powiązane posty | Odpowiedzi | Widoki | Czynność | |
|---|---|---|---|---|
|
|
0
sty 20
|
604 | ||
|
|
1
lis 22
|
5339 | ||
|
|
3
lis 21
|
29059 | ||
|
how to customize year range in date field?
Rozwiązane
|
|
1
sie 15
|
7540 | |
|
Year only needed - how to implement?
Rozwiązane
|
|
2
mar 15
|
5277 |
from_date = fields.Date(string="From Date" ,default=datetime.now())