Hello, I have a function field in a tree view that is supposed to display a calculated field, but for some reason the field is not being recalculated whenever I go to the tree view. I know the function that calculates the field is not being called because I put a breakpoint in the beginning of the method, and it never stops on that breakpoint. Does anyone know why a method for a functional field would not be called?
Here is my field definition:
'days_remaining_func': fields.function(_get_days_remaining_func, method=True, type="integer", string="Days Remaining", store=True),
Here is my method:
def _get_days_remaining_func(self, cr, uid, ids, field_name, arg, context={}):
# calculate the remaining days by subtracting the exp_date - todays date
res = {}
for rec in self.browse(cr, uid, ids):
if not rec.support_exp_date:
res.update({rec.id:{ field_name: None }})
continue
exp_date = datetime.strptime(rec.support_exp_date, "%Y-%m-%d")
todays_date = datetime.now()
days_remaining = exp_date - todays_date
days_remaining = days_remaining.days
res.update({rec.id:{ field_name: days_remaining }})
return res