Hello imohdnoo the module "Medical" provides such a function, where the patient age is calculated based on the date of birth
'age' : fields.function(_patient_age, method=True, type='char', string='Patient Age'), The function looks like this def _patient_age(self, cr, uid, ids, name, arg, context={}): def compute_age_from_dates (patient_dob): now=DateTime.now() if (patient_dob): dob=DateTime.strptime(patient_dob,'%Y-%m-%d') delta=DateTime.Age (now, dob) years_months_days = str(delta.years) +" "+ str(delta.months) +" "+" "+ str(delta.days) else: years_months_days = "No DoB !" return years_months_days result={} for patient_data in self.browse(cr, uid, ids, context=context): result[patient_data.id] = compute_age_from_dates (patient_data.dob) return result As soon as the Save Button is pressed the age is calculated Hope this helps, have a look on the "Medical" module! Markster -------------------- m2f -------------------- -- http://www.openobject.com/forum/viewtopic.php?p=47380#47380 -------------------- m2f -------------------- _______________________________________________ Tinyerp-users mailing list http://tiny.be/mailman2/listinfo/tinyerp-users
