Advertisement
Guest User

Cálculo de Edad

a guest
Sep 14th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. def onchange_edad(self, cr, uid, ids, fecha_nacimiento, context=None):
  2.     res = {}
  3.     if fecha_nacimiento:
  4.         edad = (datetime.now().date() - datetime.strptime(fecha_nacimiento, '%Y-%m-%d').date()).days / 365
  5.         if edad < 0:
  6.             edad = 0
  7.         res = {'edad': edad}
  8.     return {'value': res}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement