Odoo Help

0
1 Answer
0
Weste
4/4/14, 10:24 AM

Your onchange function should be something like this:

def onchange_getage(self,cr,uid,ids,dob,context=None):
            current_date=datetime.now()
            current_year=current_date.year
            if current_year > dob.year + 100:
                      raise osv.except_osv(_('Invalid Action!'), _('This date of birth is too old!')) 
            birth_date=parser.parse(dob)
            if (current_year>=birth_date.year):
                current_age=current_year-birth_date.year
            else:
                current_age=0
                return {'value':{'age': current_age}}
Ask a Question
Writer
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now