I need to set @api.constraints for people under 18. they shall not pass. pls help me
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
            
                1
                
                    Répondre
                
            
        
        
            
                2515
                
                    Vues
                
            
        
    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
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire| Publications associées | Réponses | Vues | Activité | |
|---|---|---|---|---|
|  | 0 févr. 22  | 4 | ||
|  | 1 mars 15  | 5292 | ||
|  | 1 mars 15  | 8793 | ||
|  | 3 juin 25  | 2046 | ||
|  | 1 janv. 25  | 18659 | 
