콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
1869 화면

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

관련 게시물 답글 화면 활동
4
12월 23
6336
3
6월 25
973
4
5월 25
2658
2
5월 25
6062
1
3월 25
1773