from odoo import models, fields, api, _ class SurveyUserInput(models.Model): _inherit = "survey.user_input" duration = fields.Integer( string="Duration", compute="_get_duration", store=True, help="Duration in hours", ) @api.depends("start_datetime", "end_datetime") def _get_duration(self): for input in self: start = input.start_datetime done = input.end_datetime if not (start and done): input.duration = 0 else: input.duration = int((done - start).total_seconds()) / 3600