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

I need to set @api.constraints for people under 18. they shall not pass. pls help me

아바타
취소
베스트 답변

Hi,

Below is a sample code by which you can get age from date of birth:

today = date.today()
if rec.date_of_birth:
rec.age = today.year - rec.date_of_birth.year
else:
rec.age = 1

Video: https://youtu.be/NlbdnA6WMd8?t=632

then you can check the age is less than 18 or not and return the validation using constrains:

See: https://www.youtube.com/watch?v=8Lz4Fy7ozfY

Thanks

아바타
취소
관련 게시물 답글 화면 활동
0
2월 22
4
1
3월 15
4886
1
3월 15
8398
3
6월 25
1201
1
1월 25
18031