Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
7863 Vizualizări

Hello Community,

I am working on odoo11 survey module.

I am assigning deadline from survey wizard  and wizard contains only date field as deadline. whereas in Answers deadline field is datetime and its show 5:30 default time value.

My requirement:  I want to show default time for deadline field in Answers is 23:59.

Try:

deadline = fields.Datetime('Deadline', help="Date by which the person can open the survey and submit answers",oldname="date_deadline", default=lambda *a: time.strftime('23:59:59'))

But  its  not  worked.

Thanks  in  advance

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

In Odoo, the Datetime field requires both the date and time field to be stored in its record. So we'll have to fetch the current datetime using the python datetime module and replace the time details from it with our deadline time.

Final Code:

deadline = fields.Datetime('Deadline', help="Date by which the person can open the survey and submit answers",oldname="date_deadline", default=datetime.now().replace(hour=23, minute=59, second=59))

Regards

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
aug. 21
5700
2
oct. 19
12827
2
feb. 23
9105
1
nov. 22
3447
2
aug. 22
7820