Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7827 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Set time default in Datetime odoo 11 แก้ไขแล้ว
1
ส.ค. 21
5664
2
ต.ค. 19
12800
2
ก.พ. 23
9033
Hide menu for all except specific group แก้ไขแล้ว
1
พ.ย. 22
3375
Live tracking in odoo. แก้ไขแล้ว
2
ส.ค. 22
7712