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
46 lines
1.3 KiB
from datetime import timedelta as tdelta
|
|
from odoo import models, fields, api, _
|
|
|
|
|
|
class SurveySurvey(models.Model):
|
|
_inherit = "survey.survey"
|
|
|
|
@api.model
|
|
def cron_close_passed_deadline_survey(self):
|
|
to_close = self.search(
|
|
[
|
|
("deadline", "!=", False),
|
|
("deadline", "<", fields.Date.today()),
|
|
]
|
|
)
|
|
if to_close:
|
|
# to_close.action_close_survey()
|
|
to_close.action_archive()
|
|
|
|
deadline = fields.Date(
|
|
string="Deadline",
|
|
copy=False,
|
|
tracking=True,
|
|
help="This survey will be automatically closed after this date.",
|
|
)
|
|
active = fields.Boolean(
|
|
tracking=True,
|
|
)
|
|
|
|
def action_send_survey(self):
|
|
self.ensure_one()
|
|
action = super(SurveySurvey, self).action_send_survey()
|
|
action["context"].update(
|
|
{
|
|
"default_deadline": self.deadline,
|
|
}
|
|
)
|
|
return action
|
|
|
|
def _track_subtype(self, init_values):
|
|
self.ensure_one()
|
|
if "active" in init_values:
|
|
return self.env.ref(
|
|
"survey_deadline_autoclose.mail_message_subtype_survey_closing"
|
|
)
|
|
return super(SurveySurvey, self)._track_subtype(init_values)
|