From 491816bed7df5bc87a7b3beab65e48e986a5a985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20FRAN=C3=87OIS?= Date: Mon, 23 Mar 2020 11:45:08 +0100 Subject: [PATCH] [ADD] survey_select_input module --- survey_select_input/__init__.py | 1 + survey_select_input/__manifest__.py | 33 ++++++++++ survey_select_input/i18n/fr.po | 52 ++++++++++++++++ .../i18n/survey_select_input.pot | 52 ++++++++++++++++ survey_select_input/models/__init__.py | 2 + survey_select_input/models/survey_survey.py | 27 +++++++++ .../models/survey_user_input.py | 13 ++++ survey_select_input/views/survey_survey.xml | 21 +++++++ .../views/survey_user_input.xml | 60 +++++++++++++++++++ 9 files changed, 261 insertions(+) create mode 100644 survey_select_input/__init__.py create mode 100644 survey_select_input/__manifest__.py create mode 100644 survey_select_input/i18n/fr.po create mode 100644 survey_select_input/i18n/survey_select_input.pot create mode 100644 survey_select_input/models/__init__.py create mode 100644 survey_select_input/models/survey_survey.py create mode 100644 survey_select_input/models/survey_user_input.py create mode 100644 survey_select_input/views/survey_survey.xml create mode 100644 survey_select_input/views/survey_user_input.xml diff --git a/survey_select_input/__init__.py b/survey_select_input/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_select_input/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_select_input/__manifest__.py b/survey_select_input/__manifest__.py new file mode 100644 index 0000000..25ea2d1 --- /dev/null +++ b/survey_select_input/__manifest__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Survey answer selection', + 'version': '1.0.0', + 'summary': """ + This module adds the mossibility to select some of the surveys answers. + """, + 'description': """ """, + 'author': 'Sudokeys', + 'website': 'http://www.sudokeys.com', + 'license': 'AGPL-3', + 'category': 'Marketing', + 'depends': [ + 'survey', + ], + 'data': [ + 'views/survey_survey.xml', + '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_select_input/i18n/fr.po b/survey_select_input/i18n/fr.po new file mode 100644 index 0000000..8dd2065 --- /dev/null +++ b/survey_select_input/i18n/fr.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_select_input +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-23 10:26+0000\n" +"PO-Revision-Date: 2020-03-23 10:26+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_select_input +#: code:addons/survey_select_input/models/survey_survey.py:26 +#, python-format +msgid " from all ones" +msgstr " de tous les sondés" + +#. module: survey_select_input +#: code:addons/survey_select_input/models/survey_survey.py:24 +#, python-format +msgid " selected" +msgstr " retenues" + +#. module: survey_select_input +#: model:ir.model.fields,field_description:survey_select_input.field_survey_survey__tot_selected_survey +msgid "Number of selected surveys" +msgstr "Nombre de réponses retenues" + +#. module: survey_select_input +#: model:ir.model.fields,field_description:survey_select_input.field_survey_user_input__selected +#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_survey_form +#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_user_input_search +#: model_terms:ir.ui.view,arch_db:survey_select_input.view_survey_user_input_kanban +msgid "Selected" +msgstr "Retenue" + +#. module: survey_select_input +#: model:ir.model,name:survey_select_input.model_survey_survey +msgid "Survey" +msgstr "Sondage" + +#. module: survey_select_input +#: model:ir.model,name:survey_select_input.model_survey_user_input +msgid "Survey User Input" +msgstr "Saisie utilisateur du sondage" + diff --git a/survey_select_input/i18n/survey_select_input.pot b/survey_select_input/i18n/survey_select_input.pot new file mode 100644 index 0000000..6a1be94 --- /dev/null +++ b/survey_select_input/i18n/survey_select_input.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_select_input +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-03-23 10:27+0000\n" +"PO-Revision-Date: 2020-03-23 10:27+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_select_input +#: code:addons/survey_select_input/models/survey_survey.py:26 +#, python-format +msgid " from all ones" +msgstr "" + +#. module: survey_select_input +#: code:addons/survey_select_input/models/survey_survey.py:24 +#, python-format +msgid " selected" +msgstr "" + +#. module: survey_select_input +#: model:ir.model.fields,field_description:survey_select_input.field_survey_survey__tot_selected_survey +msgid "Number of selected surveys" +msgstr "" + +#. module: survey_select_input +#: model:ir.model.fields,field_description:survey_select_input.field_survey_user_input__selected +#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_survey_form +#: model_terms:ir.ui.view,arch_db:survey_select_input.survey_user_input_search +#: model_terms:ir.ui.view,arch_db:survey_select_input.view_survey_user_input_kanban +msgid "Selected" +msgstr "" + +#. module: survey_select_input +#: model:ir.model,name:survey_select_input.model_survey_survey +msgid "Survey" +msgstr "" + +#. module: survey_select_input +#: model:ir.model,name:survey_select_input.model_survey_user_input +msgid "Survey User Input" +msgstr "" + diff --git a/survey_select_input/models/__init__.py b/survey_select_input/models/__init__.py new file mode 100644 index 0000000..8db4d71 --- /dev/null +++ b/survey_select_input/models/__init__.py @@ -0,0 +1,2 @@ +from . import survey_survey +from . import survey_user_input diff --git a/survey_select_input/models/survey_survey.py b/survey_select_input/models/survey_survey.py new file mode 100644 index 0000000..dd4e4be --- /dev/null +++ b/survey_select_input/models/survey_survey.py @@ -0,0 +1,27 @@ +from odoo import models, fields, api, _ + + +class SurveySurvey(models.Model): + _inherit = 'survey.survey' + + tot_selected_survey = fields.Integer("Number of selected surveys", compute="_get_selected_input") + + @api.depends('user_input_ids', 'user_input_ids.selected') + def _get_selected_input(self): + selected_survey = self.env['survey.user_input'].search([ + ('survey_id', 'in', self.ids), + ('selected', '=', True) + ]) + for survey in self: + survey.tot_selected_survey = len(selected_survey.filtered(lambda user_input: user_input.survey_id == survey)) + + # ACTIONS + + @api.multi + def action_survey_user_input(self): + action = super(SurveySurvey, self).action_survey_user_input() + if self.env.context.get('search_default_selected', False): + action['display_name'] += _(" selected") + else: + action['display_name'] += _(" from all ones") + return action diff --git a/survey_select_input/models/survey_user_input.py b/survey_select_input/models/survey_user_input.py new file mode 100644 index 0000000..b26c995 --- /dev/null +++ b/survey_select_input/models/survey_user_input.py @@ -0,0 +1,13 @@ +from odoo import models, fields, api + + +class SurveyUserInput(models.Model): + _inherit = 'survey.user_input' + + selected = fields.Boolean(string="Selected", default=False) + + @api.multi + def toggle_selected(self): + unselect = self.filtered('selected') + unselect.write({'selected': False}) + (self - unselect).write({'selected': True}) diff --git a/survey_select_input/views/survey_survey.xml b/survey_select_input/views/survey_survey.xml new file mode 100644 index 0000000..c8d90b5 --- /dev/null +++ b/survey_select_input/views/survey_survey.xml @@ -0,0 +1,21 @@ + + + + + survey_select_input survey.survey form + survey.survey + + 23 + + + + + + + diff --git a/survey_select_input/views/survey_user_input.xml b/survey_select_input/views/survey_user_input.xml new file mode 100644 index 0000000..28ff773 --- /dev/null +++ b/survey_select_input/views/survey_user_input.xml @@ -0,0 +1,60 @@ + + + + + survey_select_input survey.user_input form + survey.user_input + + 23 + +
+ +
+
+
+ + + survey_select_input survey.user_input tree + survey.user_input + + 23 + + + + + + + + + survey_select_input survey.user_input kanban + survey.user_input + + 23 + + + + + + Selected + + + + + + survey_select_input survey.user_input search + survey.user_input + + 23 + + + + + + + + +