Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1881 Lượt xem

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()

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks, it worked

Câu trả lời hay nhất

Hi Ricky Raymond

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

Thanks.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ

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()

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 12 23
6351
3
thg 6 25
979
4
thg 5 25
2666
2
thg 5 25
6068
1
thg 3 25
1782