Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2221 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lut 22
4
1
mar 15
4895
1
mar 15
8408
3
cze 25
1210
1
sty 25
18033