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.
|
|
from odoo import models, fields, api, _
class SurveyUserInput(models.Model): _inherit = "survey.user_input"
date_start = fields.Datetime( string="Start date", readonly=True, help='This date is set when the user clicks on "Start survey" button for the first time.', ) date_done = fields.Datetime( string="Date done", readonly=True, help='This date is set when the user input is set ton "Done" status.', ) duration = fields.Integer( string="Duration", compute="_get_duration", store=True, help="Time expressed in seconds, neet 'duration' widget to be read by user.", )
@api.depends("date_start", "date_stop") def _get_duration(self): for input in self: start = input.date_start done = input.date_done if not start and done: input.duration = 0 else: input.duration = int((done - start).total_seconds())
@api.multi def write(self, vals): if vals.get("state", False) == "done": vals.update( { "date_done": fields.Datetime.now(), } ) return super(SurveyUserInput, self).write(vals)
|