I'm new to odoo, I have 2 date fields, I have tried in various ways to get the calculation taken by a third field, but I can't get it to work when placing it in the view. The code I am using on the calculated field is this
for record in self:
if record.x_studio_fecha_prevista_1 and record.create_date:
date_diff = record.x_studio_fecha_prevista_1 - record.create_date
record.x_studio_calculohora = date_diff.total_seconds() / 3600
else:
record.x_studio_calculohora = False
Hi Katalina,
I did test my solution, and when the date is changed it does recalculate the number of days. That's defining the computed field as "stored".
Don't forget to include both fields as dependencies.
Having said that, I have had problems before with computed fields! Maybe someone else can offer more advice!