From c8ac00dcf79da6e909e0fdfd44819d4bfab89fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20FRAN=C3=87OIS?= Date: Mon, 4 May 2020 15:04:10 +0200 Subject: [PATCH] [ADD] survey_input_dates module --- survey_input_dates/__init__.py | 1 + survey_input_dates/__manifest__.py | 32 ++++++++++ survey_input_dates/models/__init__.py | 2 + survey_input_dates/models/survey_survey.py | 14 +++++ .../models/survey_user_input.py | 16 +++++ .../views/survey_user_input.xml | 59 +++++++++++++++++++ .../views/survey_user_input.xml | 2 +- 7 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 survey_input_dates/__init__.py create mode 100644 survey_input_dates/__manifest__.py create mode 100644 survey_input_dates/models/__init__.py create mode 100644 survey_input_dates/models/survey_survey.py create mode 100644 survey_input_dates/models/survey_user_input.py create mode 100644 survey_input_dates/views/survey_user_input.xml diff --git a/survey_input_dates/__init__.py b/survey_input_dates/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_input_dates/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_input_dates/__manifest__.py b/survey_input_dates/__manifest__.py new file mode 100644 index 0000000..3c0a602 --- /dev/null +++ b/survey_input_dates/__manifest__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Survey input dates', + 'version': '1.0.0', + 'summary': """ + This module adds date start and date done on surveys answers. + """, + 'description': """ """, + 'author': 'Sudokeys', + 'website': 'http://www.sudokeys.com', + 'license': 'AGPL-3', + 'category': 'Marketing', + 'depends': [ + 'survey', + ], + 'data': [ + 'views/survey_user_input.xml', + ], + 'demo': [], + 'auto_install': False, + 'external_dependencies': [], + 'application': False, + 'css': [], + 'images': [], + 'js': [], + 'installable': True, + 'maintainer': 'Sudokeys', + 'pre_init_hook': '', + 'post_init_hook': '', + 'uninstall_hook': '', +} diff --git a/survey_input_dates/models/__init__.py b/survey_input_dates/models/__init__.py new file mode 100644 index 0000000..8db4d71 --- /dev/null +++ b/survey_input_dates/models/__init__.py @@ -0,0 +1,2 @@ +from . import survey_survey +from . import survey_user_input diff --git a/survey_input_dates/models/survey_survey.py b/survey_input_dates/models/survey_survey.py new file mode 100644 index 0000000..8aa0430 --- /dev/null +++ b/survey_input_dates/models/survey_survey.py @@ -0,0 +1,14 @@ +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 new file mode 100644 index 0000000..1c92fbd --- /dev/null +++ b/survey_input_dates/models/survey_user_input.py @@ -0,0 +1,16 @@ +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.") + + @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 new file mode 100644 index 0000000..1ea7ce4 --- /dev/null +++ b/survey_input_dates/views/survey_user_input.xml @@ -0,0 +1,59 @@ + + + + + survey_select_input survey.user_input form + survey.user_input + + 26 + + + + + + + + + + + survey_select_input survey.user_input tree + survey.user_input + + 26 + + + + + + + + + + + survey_select_input survey.user_input kanban + survey.user_input + + 26 + + + + + + + + + + + survey_select_input survey.user_input search + survey.user_input + + 26 + + + + + + + + + diff --git a/survey_select_input/views/survey_user_input.xml b/survey_select_input/views/survey_user_input.xml index c712b08..c2a557b 100644 --- a/survey_select_input/views/survey_user_input.xml +++ b/survey_select_input/views/survey_user_input.xml @@ -43,7 +43,7 @@ Selected - +