Browse Source

[MIG] survey_input_dates to survey_input_duration

16.0
RemiFr82 6 days ago
parent
commit
9124716399
  1. 71
      survey_input_dates/i18n/fr.po
  2. 14
      survey_input_dates/models/survey_survey.py
  3. 55
      survey_input_dates/models/survey_user_input.py
  4. 65
      survey_input_dates/views/survey_user_input.xml
  5. 0
      survey_input_duration/__init__.py
  6. 14
      survey_input_duration/__manifest__.py
  7. 36
      survey_input_duration/i18n/fr.po
  8. 1
      survey_input_duration/models/__init__.py
  9. 22
      survey_input_duration/models/survey_user_input.py
  10. 58
      survey_input_duration/views/survey_user_input.xml

71
survey_input_dates/i18n/fr.po

@ -1,71 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * survey_input_dates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-28 20:38+0000\n"
"PO-Revision-Date: 2023-02-28 20:38+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: survey_input_dates
#: model:ir.model.fields,field_description:survey_input_dates.field_survey_user_input__date_done
#: model_terms:ir.ui.view,arch_db:survey_input_dates.survey_user_input_search
msgid "Date done"
msgstr "Réponse terminée le"
#. module: survey_input_dates
#: model:ir.model.fields,field_description:survey_input_dates.field_survey_user_input__duration
#: model:ir.model.fields,field_description:survey_input_dates.field_survey_user_input__duration_txt
msgid "Duration"
msgstr "Durée"
#. module: survey_input_dates
#: model:ir.model.fields,help:survey_input_dates.field_survey_user_input__duration
msgid "Duration in seconds"
msgstr "Durée en secondes"
#. module: survey_input_dates
#: code:addons/survey_input_dates/models/survey_user_input.py:39
#, python-format
msgid "Not done yet"
msgstr "Pas encore terminé"
#. module: survey_input_dates
#: code:addons/survey_input_dates/models/survey_user_input.py:36
#, python-format
msgid "Not started yet"
msgstr "Pas encore démarré"
#. module: survey_input_dates
#: model:ir.model.fields,field_description:survey_input_dates.field_survey_user_input__date_start
msgid "Start date"
msgstr "Début de réponse le"
#. module: survey_input_dates
#: model:ir.model,name:survey_input_dates.model_survey_survey
msgid "Survey"
msgstr "Sondage"
#. module: survey_input_dates
#: model:ir.model,name:survey_input_dates.model_survey_user_input
msgid "Survey User Input"
msgstr "Saisie utilisateur du sondage"
#. module: survey_input_dates
#: model:ir.model.fields,help:survey_input_dates.field_survey_user_input__date_start
msgid "This date is set when the user clicks on \"Start survey\" button for the first time."
msgstr "Cette date est renseignée lorsque le répondant clique sur le bouton \"Répondre\" pour la première fois."
#. module: survey_input_dates
#: model:ir.model.fields,help:survey_input_dates.field_survey_user_input__date_done
msgid "This date is set when the user input is set ton \"Done\" status."
msgstr "Cette date est renseignée lorsque la réponse passe au statut \"Terminé\"."

14
survey_input_dates/models/survey_survey.py

@ -1,14 +0,0 @@
from odoo import models, fields, api
class SurveySurvey(models.Model):
_inherit = 'survey.survey'
@api.model
def next_page(self, user_input, page_id, go_back=False):
res = super(SurveySurvey, self).next_page(user_input, page_id, go_back)
if not user_input.date_start and page_id == 0:
user_input.write({
'date_start': fields.Datetime.now(),
})
return res

55
survey_input_dates/models/survey_user_input.py

@ -1,55 +0,0 @@
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="Duration in seconds",
)
duration_txt = fields.Char(
string="Duration",
compute="_get_duration",
store=True,
)
@api.depends("date_start", "date_done")
def _get_duration(self):
for input in self:
start = input.date_start
done = input.date_done
if not start:
input.duration = 0
input.duration_txt = _("Not started yet")
elif not done:
input.duration = 0
input.duration_txt = _("Not done yet")
else:
input.duration = int((done - start).total_seconds())
input.duration_txt = self.env["ir.qweb.field.duration"].value_to_html(
(done - start).total_seconds(),
{"unit": "second", "round": "second"},
)
@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)

65
survey_input_dates/views/survey_user_input.xml

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="survey_user_input_form" model="ir.ui.view">
<field name="name">survey_input_dates survey.user_input form</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_form"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<field name="date_create" position="after">
<field name="date_start"/>
<field name="date_done"/>
<field name="duration" invisible="1"/>
<field name="duration_txt"/>
</field>
</field>
</record>
<record id="survey_user_input_tree" model="ir.ui.view">
<field name="name">survey_input_dates survey.user_input tree</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_tree"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<field name="date_create" position="after">
<field name="date_start"/>
<field name="date_done"/>
<field name="duration" invisible="1"/>
<field name="duration_txt"/>
</field>
</field>
</record>
<record id="view_survey_user_input_kanban" model="ir.ui.view">
<field name="name">survey_input_dates survey.user_input kanban</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.view_survey_user_input_kanban"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<field name="date_create" position="after">
<field name="date_start"/>
<field name="date_done"/>
<field name="duration"/>
<field name="duration_txt"/>
</field>
</field>
</record>
<record id="survey_user_input_search" model="ir.ui.view">
<field name="name">survey_input_dates survey.user_input search</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_search"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<filter name="group_by_partner" position="after">
<filter string="Date done" name="by_date_done" domain="[]" context="{'group_by': 'date_done:week'}"/>
</filter>
</field>
</record>
</odoo>

0
survey_input_dates/__init__.py → survey_input_duration/__init__.py

14
survey_input_dates/__manifest__.py → survey_input_duration/__manifest__.py

@ -1,23 +1,24 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Survey input dates",
"name": "Survey input duration",
"version": "1.0.0",
"summary": """
Add start and done dates on survey answers
Compute duration on survey answers
""",
"description": """
This module adds start and done dates on surveys answers, and computes filling duration, readable by human.
This module computes surveys filling duration based on start and done dates and times.
""",
"author": "RemiFr82",
"contributors": "Sudokeys",
"contributors": "",
"website": "https://remifr82.me",
"maintainer": "RemiFr82",
"license": "LGPL-3",
"category": "Marketing",
# "price": 0,
# "price": 5,
# "currency": "EUR",
"application": False,
"installable": False,
"installable": True,
"auto_install": False,
"pre_init_hook": "",
"post_init_hook": "",
@ -35,5 +36,4 @@
"js": [],
"test": [],
"demo": [],
"maintainer": "RemiFr82",
}

36
survey_input_duration/i18n/fr.po

@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * survey_input_duration
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0-20230613\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-28 16:49+0000\n"
"PO-Revision-Date: 2024-12-28 16:49+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: survey_input_duration
#: model_terms:ir.ui.view,arch_db:survey_input_duration.survey_user_input_view_search
msgid "Date done"
msgstr "Date de fin"
#. module: survey_input_duration
#: model:ir.model.fields,field_description:survey_input_duration.field_survey_user_input__duration
msgid "Duration"
msgstr "Durée"
#. module: survey_input_duration
#: model:ir.model.fields,help:survey_input_duration.field_survey_user_input__duration
msgid "Duration in hours"
msgstr "Durée en heures"
#. module: survey_input_duration
#: model:ir.model,name:survey_input_duration.model_survey_user_input
msgid "Survey User Input"
msgstr "Entrée utilisateur du sondage"

1
survey_input_dates/models/__init__.py → survey_input_duration/models/__init__.py

@ -1,2 +1 @@
from . import survey_survey
from . import survey_user_input

22
survey_input_duration/models/survey_user_input.py

@ -0,0 +1,22 @@
from odoo import models, fields, api, _
class SurveyUserInput(models.Model):
_inherit = "survey.user_input"
duration = fields.Integer(
string="Duration",
compute="_get_duration",
store=True,
help="Duration in hours",
)
@api.depends("start_datetime", "end_datetime")
def _get_duration(self):
for input in self:
start = input.start_datetime
done = input.end_datetime
if not (start and done):
input.duration = 0
else:
input.duration = int((done - start).total_seconds()) / 3600

58
survey_input_duration/views/survey_user_input.xml

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="survey_user_input_view_form" model="ir.ui.view">
<field name="name">survey_input_duration survey.user_input form</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_view_form" />
<field name="priority">26</field>
<field name="arch" type="xml">
<field name="deadline" position="after">
<field name="start_datetime" />
<field name="end_datetime" />
<field name="duration" widget="float_time" />
</field>
</field>
</record>
<record id="survey_user_input_view_tree" model="ir.ui.view">
<field name="name">survey_input_duration survey.user_input tree</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_view_tree" />
<field name="priority">26</field>
<field name="arch" type="xml">
<field name="deadline" position="after">
<field name="start_datetime" optional="hide" />
<field name="end_datetime" optional="hide" />
<field name="duration" widget="float_time" optional="show" />
</field>
</field>
</record>
<record id="survey_user_input_viuew_kanban" model="ir.ui.view">
<field name="name">survey_input_duration survey.user_input kanban</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_viuew_kanban" />
<field name="priority">26</field>
<field name="arch" type="xml">
<field name="create_date" position="after">
<field name="start_datetime" />
<field name="end_datetime" />
<field name="duration" />
</field>
</field>
</record>
<record id="survey_user_input_view_search" model="ir.ui.view">
<field name="name">survey_input_duration survey.user_input search</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_view_search" />
<field name="priority">26</field>
<field name="arch" type="xml">
<filter name="group_by_partner" position="after">
<filter string="Date done" name="by_end_datetime" domain="[]" context="{'group_by': 'end_datetime'}" />
</filter>
</field>
</record>
</odoo>
Loading…
Cancel
Save