From 91247163995d860b447fa9f77b09f82ad4689d97 Mon Sep 17 00:00:00 2001 From: RemiFr82 Date: Sat, 28 Dec 2024 17:51:44 +0100 Subject: [PATCH] [MIG] survey_input_dates to survey_input_duration --- survey_input_dates/i18n/fr.po | 71 ------------------- survey_input_dates/models/survey_survey.py | 14 ---- .../models/survey_user_input.py | 55 -------------- .../views/survey_user_input.xml | 65 ----------------- .../__init__.py | 0 .../__manifest__.py | 14 ++-- survey_input_duration/i18n/fr.po | 36 ++++++++++ .../models/__init__.py | 1 - .../models/survey_user_input.py | 22 ++++++ .../views/survey_user_input.xml | 58 +++++++++++++++ 10 files changed, 123 insertions(+), 213 deletions(-) delete mode 100644 survey_input_dates/i18n/fr.po delete mode 100644 survey_input_dates/models/survey_survey.py delete mode 100644 survey_input_dates/models/survey_user_input.py delete mode 100644 survey_input_dates/views/survey_user_input.xml rename {survey_input_dates => survey_input_duration}/__init__.py (100%) rename {survey_input_dates => survey_input_duration}/__manifest__.py (72%) create mode 100644 survey_input_duration/i18n/fr.po rename {survey_input_dates => survey_input_duration}/models/__init__.py (53%) create mode 100644 survey_input_duration/models/survey_user_input.py create mode 100644 survey_input_duration/views/survey_user_input.xml diff --git a/survey_input_dates/i18n/fr.po b/survey_input_dates/i18n/fr.po deleted file mode 100644 index c8d4f1f..0000000 --- a/survey_input_dates/i18n/fr.po +++ /dev/null @@ -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é\"." - diff --git a/survey_input_dates/models/survey_survey.py b/survey_input_dates/models/survey_survey.py deleted file mode 100644 index 8aa0430..0000000 --- a/survey_input_dates/models/survey_survey.py +++ /dev/null @@ -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 diff --git a/survey_input_dates/models/survey_user_input.py b/survey_input_dates/models/survey_user_input.py deleted file mode 100644 index 9ac42a7..0000000 --- a/survey_input_dates/models/survey_user_input.py +++ /dev/null @@ -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) diff --git a/survey_input_dates/views/survey_user_input.xml b/survey_input_dates/views/survey_user_input.xml deleted file mode 100644 index d2c3d38..0000000 --- a/survey_input_dates/views/survey_user_input.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - survey_input_dates survey.user_input form - survey.user_input - - 26 - - - - - - - - - - - - - survey_input_dates survey.user_input tree - survey.user_input - - 26 - - - - - - - - - - - - - survey_input_dates survey.user_input kanban - survey.user_input - - 26 - - - - - - - - - - - - - survey_input_dates survey.user_input search - survey.user_input - - 26 - - - - - - - - - diff --git a/survey_input_dates/__init__.py b/survey_input_duration/__init__.py similarity index 100% rename from survey_input_dates/__init__.py rename to survey_input_duration/__init__.py diff --git a/survey_input_dates/__manifest__.py b/survey_input_duration/__manifest__.py similarity index 72% rename from survey_input_dates/__manifest__.py rename to survey_input_duration/__manifest__.py index 9a57f0f..68cb425 100644 --- a/survey_input_dates/__manifest__.py +++ b/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", } diff --git a/survey_input_duration/i18n/fr.po b/survey_input_duration/i18n/fr.po new file mode 100644 index 0000000..5484ba4 --- /dev/null +++ b/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" diff --git a/survey_input_dates/models/__init__.py b/survey_input_duration/models/__init__.py similarity index 53% rename from survey_input_dates/models/__init__.py rename to survey_input_duration/models/__init__.py index 8db4d71..56623b5 100644 --- a/survey_input_dates/models/__init__.py +++ b/survey_input_duration/models/__init__.py @@ -1,2 +1 @@ -from . import survey_survey from . import survey_user_input diff --git a/survey_input_duration/models/survey_user_input.py b/survey_input_duration/models/survey_user_input.py new file mode 100644 index 0000000..af81aba --- /dev/null +++ b/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 diff --git a/survey_input_duration/views/survey_user_input.xml b/survey_input_duration/views/survey_user_input.xml new file mode 100644 index 0000000..660d032 --- /dev/null +++ b/survey_input_duration/views/survey_user_input.xml @@ -0,0 +1,58 @@ + + + + + survey_input_duration survey.user_input form + survey.user_input + + 26 + + + + + + + + + + + survey_input_duration survey.user_input tree + survey.user_input + + 26 + + + + + + + + + + + survey_input_duration survey.user_input kanban + survey.user_input + + 26 + + + + + + + + + + + survey_input_duration survey.user_input search + survey.user_input + + 26 + + + + + + + +