I am trying to compute the days since of a book release date. while creating a new record, the code showing an error.
Something went wrong !
I would like to solve this problem using filtered(lambda function).
date_release = fields.Date('Release Date', copy=False)
age_days = fields.Float(string='Days Since Release', compute='_compute_age')
def _compute_age(self): #self: library.book(,)
today = fields.Date.today() #today: 2021-06-16
for book in self.filtered(lambda x: x.date_release):
delta = today - book.date_release
book.age_days = delta.days