Browse Source

[IMP] survey_deadline_autoclose

16.0
RemiFr82 5 days ago
parent
commit
2ec606e232
  1. 37
      survey_deadline_autoclose/i18n/fr.po
  2. 26
      survey_deadline_autoclose/models/survey_survey.py
  3. 30
      survey_deadline_autoclose/views/survey_survey.xml

37
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 ""
"<span class=\"fw-bold\">Deadline</span>\n"
" <br/>"
"#{record.auto_close.raw_value ? 'Survey will be automatically closed once "
"deadline passed' : ''}"
msgstr ""
"<span class=\"fw-bold\">Échéance</span>\n"
" <br/>"
"#{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."

26
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:

30
survey_deadline_autoclose/views/survey_survey.xml

@ -8,7 +8,12 @@
<field name="priority">28</field>
<field name="arch" type="xml">
<field name="scoring_type" position="before">
<field name="deadline" />
<label for="deadline" />
<div class="o_row">
<field name="deadline" class="oe_inline" />
<label for="auto_close" string="Automatic closing ?" attrs="{'invisible': [('deadline', '=', False)]}" />
<field name="auto_close" attrs="{'invisible': [('deadline', '=', False)]}" />
</div>
</field>
</field>
</record>
@ -21,6 +26,7 @@
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="deadline" />
<field name="auto_close" />
</field>
</field>
</record>
@ -31,18 +37,20 @@
<field name="inherit_id" ref="survey.survey_survey_view_kanban" />
<field name="priority">28</field>
<field name="arch" type="xml">
<field name="color" position="after">
<field name="auto_close" />
</field>
<xpath expr="//div[hasclass('o_survey_kanban_card_ungrouped', 'row', 'mx-0')]/div[1]" position="after">
<div t-if="!selection_mode" class="col-lg-1 col-sm-4 col-6 py-0 my-2">
<span class="fw-bold">Deadline</span>
<br />
<span class="text-muted">
<t t-if="record.deadline.raw_value">
<field name="deadline" widget="date" />
</t>
<t t-else="">
<i>Undefined</i>
</t>
<div t-if="!selection_mode and record.deadline.raw_value" class="col-lg-1 col-sm-4 col-6 py-0 my-2">
<span t-attf-class="fw-bold">
<field name="deadline" widget="date" />
</span>
<br />
<span class="text-muted"
t-attf-title="#{record.auto_close.raw_value ? 'Survey will be automatically closed once deadline passed' : ''}">
Deadline <i t-if="record.auto_close.raw_value" class="fa fa-cogs" /> <i
t-if="record.auto_close.raw_value" class="fa fa-long-arrow-right" /> <i
t-if="record.auto_close.raw_value" class="fa fa-archive" /></span>
</div>
</xpath>
</field>

Loading…
Cancel
Save