I have two fields such as date_of_birth and age.
date_of_birth = fields.Date(string='Date of Birth')
age = fields.Char(string='Age', compute='_compute_age')
@api.depends('date_of_birth') def _compute_age(self):
for rec in self:
dt = rec.date_of_birth
d2 = date.today()
d1 = datetime.strptime(dt, "%Y-%m-%d").date()
rd = relativedelta(d2, d1)
rec.age = str(rd.years) + ' years ' + str(rd.months) + ' months ' + str(rd.days) + ' days'
I want to auto compute to update the age field every day. How do I do that?
Thanks in advance