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.

46 lines
1.3 KiB

  1. from datetime import timedelta as tdelta
  2. from odoo import models, fields, api, _
  3. class SurveySurvey(models.Model):
  4. _inherit = "survey.survey"
  5. @api.model
  6. def cron_close_passed_deadline_survey(self):
  7. to_close = self.search(
  8. [
  9. ("deadline", "!=", False),
  10. ("deadline", "<", fields.Date.today()),
  11. ]
  12. )
  13. if to_close:
  14. # to_close.action_close_survey()
  15. to_close.action_archive()
  16. deadline = fields.Date(
  17. string="Deadline",
  18. copy=False,
  19. tracking=True,
  20. help="This survey will be automatically closed after this date.",
  21. )
  22. active = fields.Boolean(
  23. tracking=True,
  24. )
  25. def action_send_survey(self):
  26. self.ensure_one()
  27. action = super(SurveySurvey, self).action_send_survey()
  28. action["context"].update(
  29. {
  30. "default_deadline": self.deadline,
  31. }
  32. )
  33. return action
  34. def _track_subtype(self, init_values):
  35. self.ensure_one()
  36. if "active" in init_values:
  37. return self.env.ref(
  38. "survey_deadline_autoclose.mail_message_subtype_survey_closing"
  39. )
  40. return super(SurveySurvey, self)._track_subtype(init_values)