diff --git a/survey_deadline_autoclose/i18n/fr.po b/survey_deadline_autoclose/i18n/fr.po
index b5c3199..5173cd7 100644
--- a/survey_deadline_autoclose/i18n/fr.po
+++ b/survey_deadline_autoclose/i18n/fr.po
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0-20230613\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2024-12-27 14:59+0000\n"
-"PO-Revision-Date: 2024-12-27 14:59+0000\n"
+"POT-Creation-Date: 2024-12-28 17:42+0000\n"
+"PO-Revision-Date: 2024-12-28 17:42+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -18,17 +18,27 @@ msgstr ""
#. module: survey_deadline_autoclose
#: model_terms:ir.ui.view,arch_db:survey_deadline_autoclose.survey_survey_view_kanban
msgid ""
-"Deadline\n"
-"
"
+"#{record.auto_close.raw_value ? 'Survey will be automatically closed once "
+"deadline passed' : ''}"
msgstr ""
-"Échéance\n"
-"
"
+"#{record.auto_close.raw_value ? 'Le sondage sera automatiquement fermé une "
+"fois échu' : ''}"
#. module: survey_deadline_autoclose
#: model:ir.model.fields,field_description:survey_deadline_autoclose.field_survey_survey__active
msgid "Active"
msgstr "Actif"
+#. module: survey_deadline_autoclose
+#: model:ir.model.fields,field_description:survey_deadline_autoclose.field_survey_survey__auto_close
+msgid "Auto closing"
+msgstr "Clôture auto"
+
+#. module: survey_deadline_autoclose
+#: model_terms:ir.ui.view,arch_db:survey_deadline_autoclose.survey_survey_view_form
+msgid "Automatic closing ?"
+msgstr "Clôture auto ?"
+
#. module: survey_deadline_autoclose
#: model:ir.actions.server,name:survey_deadline_autoclose.cron_close_expired_surveys_ir_actions_server
#: model:ir.cron,cron_name:survey_deadline_autoclose.cron_close_expired_surveys
@@ -42,16 +52,27 @@ msgstr "Fermeture"
#. module: survey_deadline_autoclose
#: model:ir.model.fields,field_description:survey_deadline_autoclose.field_survey_survey__deadline
+#: model_terms:ir.ui.view,arch_db:survey_deadline_autoclose.survey_survey_view_kanban
#: model_terms:ir.ui.view,arch_db:survey_deadline_autoclose.survey_survey_view_search
msgid "Deadline"
msgstr "Échéance"
+#. module: survey_deadline_autoclose
+#: model:ir.model.fields,help:survey_deadline_autoclose.field_survey_survey__auto_close
+msgid "If checked, this survey will be automatically closed after the deadline."
+msgstr "Si coché, ce sondage sera automatiquement clos après échéance."
+
#. module: survey_deadline_autoclose
#: model:ir.model,name:survey_deadline_autoclose.model_survey_survey
msgid "Survey"
msgstr "Sondage"
+#. module: survey_deadline_autoclose
+#: model:mail.message.subtype,description:survey_deadline_autoclose.mail_message_subtype_survey_closing
+msgid "Survey closing"
+msgstr "Clôture"
+
#. module: survey_deadline_autoclose
#: model:ir.model.fields,help:survey_deadline_autoclose.field_survey_survey__deadline
-msgid "This survey will be automatically closed after this date."
-msgstr "Ce sondage sera automatiquement clos passé cette date"
+msgid "The day after date at 00:00 will be set as default answer deadline on survey sharing."
+msgstr "Le lendemain de cette date à 00:00 sera utilisé comme échéance de réponse lors du partage du sondage."
diff --git a/survey_deadline_autoclose/models/survey_survey.py b/survey_deadline_autoclose/models/survey_survey.py
index 42eacc8..c779c90 100644
--- a/survey_deadline_autoclose/models/survey_survey.py
+++ b/survey_deadline_autoclose/models/survey_survey.py
@@ -1,5 +1,6 @@
-from datetime import timedelta as tdelta
-from odoo import models, fields, api, _
+from datetime import timedelta
+from pytz import timezone, utc
+from odoo import models, fields, api
class SurveySurvey(models.Model):
@@ -11,17 +12,21 @@ class SurveySurvey(models.Model):
[
("deadline", "!=", False),
("deadline", "<", fields.Date.today()),
+ ("auto_close", "=", True),
]
)
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.",
+ help="The day after date at 00:00 will be set as default answer deadline on survey sharing.",
+ )
+ auto_close = fields.Boolean(
+ string="Auto closing",
+ help="If checked, this survey will be automatically closed after the deadline.",
)
active = fields.Boolean(
tracking=True,
@@ -32,11 +37,22 @@ class SurveySurvey(models.Model):
action = super(SurveySurvey, self).action_send_survey()
action["context"].update(
{
- "default_deadline": self.deadline,
+ "default_deadline": timezone(self.env.user.tz)
+ .localize(
+ fields.Datetime.to_datetime(fields.Date.to_string(self.deadline))
+ + timedelta(days=1)
+ )
+ .astimezone(utc),
}
)
return action
+ @api.onchange("deadline")
+ def onchange_deadline(self):
+ self.ensure_one()
+ if not self.deadline and self.auto_close:
+ self.auto_close = False
+
def _track_subtype(self, init_values):
self.ensure_one()
if "active" in init_values:
diff --git a/survey_deadline_autoclose/views/survey_survey.xml b/survey_deadline_autoclose/views/survey_survey.xml
index c5c3803..6bbb60f 100644
--- a/survey_deadline_autoclose/views/survey_survey.xml
+++ b/survey_deadline_autoclose/views/survey_survey.xml
@@ -8,7 +8,12 @@
28
-
+
+
+
+
+
+
@@ -21,6 +26,7 @@
+
@@ -31,18 +37,20 @@
28
+
+
+
-
-
Deadline
-
-
-
-
-
-
- Undefined
-
+
+
+
+
+
+ Deadline