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

Hi guys!!!

Please i want to get the date of the recordset not the date of the system.

_defaults= {

'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),

}

But i want to get the date when i press on save not the date of the system. Can anyone help me please

อวตาร
ละทิ้ง

Hello, You want to display create date in form view or tree view?

คำตอบที่ดีที่สุด

Hello Abdelwahed,

If you want to get date on when press save button

you should  try to make functional field or used to create method

Updated answer

follow bellow step you will get the date when press save button

step 1: Import the library

import time

step 2: define the field

date = fields.Char(compute='_compute_date')

step 3: define the method

@api.one

def _compute_date(self):

self.date = time.strftime('%d/%m/%Y')

Let me know if this doesn't work.

If you like my answer then give me vote

Updated answer

You just create like

create_date = fields.Datetime('Date')

Also in XML file you should define like

<field name="create_date"/>
Thanks & Regards

Ankit H Gandhi

อวตาร
ละทิ้ง
ผู้เขียน

Thanks a lot for the answer but what am i going to put in my function please??

ผู้เขียน

Thanks again for the answer but it doesnt work. Here is the error: TypeError: 'str' object is not callable

Can I see your code ??

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 25
1430
0
ม.ค. 25
3530
1
ส.ค. 23
14880
change password แก้ไขแล้ว
1
ส.ค. 23
13542
1
ก.ค. 23
10517