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

I have 2 field that consist :


date_checked (datetime)

checked (boolean)


What i want is if boolean checked then date_checked autofill to field.datetime.now()

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

Thanks, it worked

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

Hi Ricky Raymond

You can use odoo onchange method through achive it this requirement.

Thanks.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Already tried using this on change but not working. Or maybe something wrong in my code


@api.onchange('is_approved')
def _change_date(self):
if self.is_approved = True
self.self.approved_date = fields.Datetime.now()
else:
self.approved_date = None


อวตาร
ละทิ้ง

Hi please
in your python if condition is wrong that's why Ricky
there are two way check boolean field true or not you direct use
if self.is_approved: or if self.is_approved == True:

if self.is_approved = True
this is wrong in python syntax

self.self.approved_date = fields.Datetime.now()
in this line only one time use
self.approved_date = fields.Datetime.now()

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ธ.ค. 23
6334
3
มิ.ย. 25
973
4
พ.ค. 25
2645
2
พ.ค. 25
6059
1
มี.ค. 25
1761