Odoo modules related to surveys
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
619 B

  1. from odoo import models, fields, api, _
  2. class SurveyUserInput(models.Model):
  3. _inherit = "survey.user_input"
  4. duration = fields.Integer(
  5. string="Duration",
  6. compute="_get_duration",
  7. store=True,
  8. help="Duration in hours",
  9. )
  10. @api.depends("start_datetime", "end_datetime")
  11. def _get_duration(self):
  12. for input in self:
  13. start = input.start_datetime
  14. done = input.end_datetime
  15. if not (start and done):
  16. input.duration = 0
  17. else:
  18. input.duration = int((done - start).total_seconds()) / 3600