From 0635b3626e425136a2f660a44d582ca5a4d959f2 Mon Sep 17 00:00:00 2001 From: Juan Jose Scarafia Date: Thu, 20 Aug 2020 17:34:12 -0300 Subject: [PATCH] [REM] survey_conditional_questions no longer needed and also with a bug. On odoo v13 this is already in odoo If needed, we should fix/improve "def validate_question(self, post, answer_tag):" --- survey_conditional_questions/README.rst | 70 ----------------- survey_conditional_questions/__init__.py | 6 -- survey_conditional_questions/__manifest__.py | 42 ----------- .../controllers/__init__.py | 5 -- .../controllers/main.py | 75 ------------------- survey_conditional_questions/i18n/en.po | 53 ------------- survey_conditional_questions/i18n/es.po | 50 ------------- .../i18n/survey_conditional_questions.pot | 52 ------------- .../models/__init__.py | 6 -- .../models/survey_question.py | 58 -------------- .../models/survey_user_input.py | 28 ------- .../views/survey_question_qweb.xml | 8 -- .../views/survey_question_views.xml | 17 ----- 13 files changed, 470 deletions(-) delete mode 100644 survey_conditional_questions/README.rst delete mode 100644 survey_conditional_questions/__init__.py delete mode 100644 survey_conditional_questions/__manifest__.py delete mode 100644 survey_conditional_questions/controllers/__init__.py delete mode 100644 survey_conditional_questions/controllers/main.py delete mode 100644 survey_conditional_questions/i18n/en.po delete mode 100644 survey_conditional_questions/i18n/es.po delete mode 100644 survey_conditional_questions/i18n/survey_conditional_questions.pot delete mode 100644 survey_conditional_questions/models/__init__.py delete mode 100644 survey_conditional_questions/models/survey_question.py delete mode 100644 survey_conditional_questions/models/survey_user_input.py delete mode 100644 survey_conditional_questions/views/survey_question_qweb.xml delete mode 100644 survey_conditional_questions/views/survey_question_views.xml diff --git a/survey_conditional_questions/README.rst b/survey_conditional_questions/README.rst deleted file mode 100644 index c009007..0000000 --- a/survey_conditional_questions/README.rst +++ /dev/null @@ -1,70 +0,0 @@ -.. |company| replace:: ADHOC SA - -.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png - :alt: ADHOC SA - :target: https://www.adhoc.com.ar - -.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png - -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - -============================ -Survey Conditional Questions -============================ - -This module add the Survey Conditional Questions. - -Installation -============ - -To install this module, you need to: - -#. Only need to install the module - -Configuration -============= - -To configure this module, you need to: - -#. Nothing to configure - -Usage -===== - -To use this module, you need to: - -#. Go to ... - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: http://runbot.adhoc.com.ar/ - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed feedback. - -Credits -======= - -Images ------- - -* |company| |icon| - -Contributors ------------- - -Maintainer ----------- - -|company_logo| - -This module is maintained by the |company|. - -To contribute to this module, please visit https://www.adhoc.com.ar. diff --git a/survey_conditional_questions/__init__.py b/survey_conditional_questions/__init__.py deleted file mode 100644 index bc704a0..0000000 --- a/survey_conditional_questions/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################## -# For copyright and license notices, see __manifest__.py file in module root -# directory -############################################################################## -from . import models -from . import controllers diff --git a/survey_conditional_questions/__manifest__.py b/survey_conditional_questions/__manifest__.py deleted file mode 100644 index dd7183e..0000000 --- a/survey_conditional_questions/__manifest__.py +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################## -# -# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar) -# All Rights Reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -{ - 'name': 'Survey Conditional Questions', - 'version': '12.0.1.0.0', - 'category': 'Warehouse Management', - 'sequence': 14, - 'summary': '', - 'author': 'ADHOC SA', - 'website': 'www.adhoc.com.ar', - 'license': 'AGPL-3', - 'depends': [ - 'survey', - 'website' - ], - 'data': [ - 'views/survey_question_views.xml', - 'views/survey_question_qweb.xml', - ], - 'demo': [ - ], - 'installable': True, - 'auto_install': False, - 'application': False, -} diff --git a/survey_conditional_questions/controllers/__init__.py b/survey_conditional_questions/controllers/__init__.py deleted file mode 100644 index 0429813..0000000 --- a/survey_conditional_questions/controllers/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -############################################################################## -# For copyright and license notices, see __manifest__.py file in module root -# directory -############################################################################## -from . import main diff --git a/survey_conditional_questions/controllers/main.py b/survey_conditional_questions/controllers/main.py deleted file mode 100644 index 4220ee0..0000000 --- a/survey_conditional_questions/controllers/main.py +++ /dev/null @@ -1,75 +0,0 @@ -############################################################################## -# For copyright and license notices, see __manifest__.py file in module root -# directory -############################################################################## - -import logging -from odoo.addons.survey.controllers.main import Survey -from odoo import http -from odoo.http import request - - -_logger = logging.getLogger(__name__) - - -class SurveyConditional(Survey): - - # TODO deberiamos heredar esto correctamente - @http.route() - def fill_survey(self, survey, token, prev=None, **post): - '''Display and validates a survey''' - Survey = request.env['survey.survey'] - UserInput = request.env['survey.user_input'] - - # Controls if the survey can be displayed - errpage = self._check_bad_cases(survey) - if errpage: - return errpage - - # Load the user_input - user_input = UserInput.sudo().search([('token', '=', token)], limit=1) - if not user_input: # Invalid token - return request.render("survey.403", {'survey': survey}) - - # Do not display expired survey (even if some pages have already been - # displayed -- There's a time for everything!) - errpage = self._check_deadline(user_input) - if errpage: - return errpage - - # Select the right page - if user_input.state == 'new': # First page - page, page_nr, last = Survey.next_page( - user_input, 0, go_back=False) - data = {'survey': survey, 'page': page, - 'page_nr': page_nr, 'token': user_input.token} - data['hide_question_ids'] = UserInput.get_list_questions( - survey, user_input) - if last: - data.update({'last': True}) - return request.render('survey.survey', data) - elif user_input.state == 'done': # Display success message - return request.render( - 'survey.sfinished', - {'survey': survey, 'token': token, 'user_input': user_input}) - elif user_input.state == 'skip': - flag = (True if prev and prev == 'prev' else False) - page, page_nr, last = Survey.next_page( - user_input, user_input.last_displayed_page_id.id, go_back=flag) - - # special case if you click "previous" from the last page, - # then leave the survey, then reopen it from the URL, avoid crash - if not page: - page, page_nr, last = Survey.next_page( - user_input, user_input.last_displayed_page_id.id, - go_back=True) - - data = {'survey': survey, 'page': page, - 'page_nr': page_nr, 'token': user_input.token} - if last: - data.update({'last': True}) - data['hide_question_ids'] = UserInput.get_list_questions( - survey, user_input) - return request.render('survey.survey', data) - else: - return request.render("survey.403", {'survey': survey}) diff --git a/survey_conditional_questions/i18n/en.po b/survey_conditional_questions/i18n/en.po deleted file mode 100644 index 4da32bb..0000000 --- a/survey_conditional_questions/i18n/en.po +++ /dev/null @@ -1,53 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_conditional_questions -# -# Translators: -msgid "" -msgstr "" -"Project-Id-Version: odoo-addons (8.0)\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-09-09 23:58+0000\n" -"PO-Revision-Date: 2015-09-01 17:53+0000\n" -"Last-Translator: Juan Jose Scarafia \n" -"Language-Team: English (http://www.transifex.com/adhoc/ingadhoc-odoo-addons-8-0/language/en/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: en\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: survey_conditional_questions -#: field:survey.question,answer_id:0 -msgid "Answer" -msgstr "Answer" - -#. module: survey_conditional_questions -#: field:survey.question,conditional:0 -msgid "Conditional Question" -msgstr "Conditional Question" - -#. module: survey_conditional_questions -#: help:survey.question,question_conditional_id:0 -msgid "In order to edit this field you should first save the question" -msgstr "In order to edit this field you should first save the question" - -#. module: survey_conditional_questions -#: field:survey.question,question_conditional_id:0 -msgid "Question" -msgstr "Question" - -#. module: survey_conditional_questions -#: model:ir.model,name:survey_conditional_questions.model_survey_question -msgid "Survey Question" -msgstr "Survey Question" - -#. module: survey_conditional_questions -#: model:ir.model,name:survey_conditional_questions.model_survey_user_input -msgid "Survey User Input" -msgstr "Survey User Input" - -#. module: survey_conditional_questions -#: view:website:survey.page -msgid "question.id not in hide_question_ids" -msgstr "question.id not in hide_question_ids" diff --git a/survey_conditional_questions/i18n/es.po b/survey_conditional_questions/i18n/es.po deleted file mode 100644 index 8646c54..0000000 --- a/survey_conditional_questions/i18n/es.po +++ /dev/null @@ -1,50 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_conditional_questions -# -# Translators: -# Juan José Scarafía , 2019 -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-10 19:24+0000\n" -"PO-Revision-Date: 2019-11-20 00:58+0000\n" -"Last-Translator: Juan José Scarafía , 2019\n" -"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/46451/es/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: es\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: survey_conditional_questions -#: model:ir.model.fields,field_description:survey_conditional_questions.field_survey_question__answer_id -msgid "Answer" -msgstr "Respuesta" - -#. module: survey_conditional_questions -#: model:ir.model.fields,field_description:survey_conditional_questions.field_survey_question__conditional -msgid "Conditional Question" -msgstr "Pregunta Condicional" - -#. module: survey_conditional_questions -#: model:ir.model.fields,help:survey_conditional_questions.field_survey_question__question_conditional_id -msgid "In order to edit this field you should first save the question" -msgstr "Para editar este campo , primero debe guardar la pregunta" - -#. module: survey_conditional_questions -#: model:ir.model.fields,field_description:survey_conditional_questions.field_survey_question__question_conditional_id -msgid "Question" -msgstr "Pregunta" - -#. module: survey_conditional_questions -#: model:ir.model,name:survey_conditional_questions.model_survey_question -msgid "Survey Question" -msgstr "Pregunta de la Encuesta" - -#. module: survey_conditional_questions -#: model:ir.model,name:survey_conditional_questions.model_survey_user_input -msgid "Survey User Input" -msgstr "Entrada de usuario de la encuesta" diff --git a/survey_conditional_questions/i18n/survey_conditional_questions.pot b/survey_conditional_questions/i18n/survey_conditional_questions.pot deleted file mode 100644 index 763b0f6..0000000 --- a/survey_conditional_questions/i18n/survey_conditional_questions.pot +++ /dev/null @@ -1,52 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_conditional_questions -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-04-23 16:32+0000\n" -"PO-Revision-Date: 2015-04-23 16:32+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_conditional_questions -#: field:survey.question,answer_id:0 -msgid "Answer" -msgstr "" - -#. module: survey_conditional_questions -#: field:survey.question,conditional:0 -msgid "Conditional Question" -msgstr "" - -#. module: survey_conditional_questions -#: help:survey.question,question_conditional_id:0 -msgid "In order to edit this field you should first save the question" -msgstr "" - -#. module: survey_conditional_questions -#: field:survey.question,question_conditional_id:0 -msgid "Question" -msgstr "" - -#. module: survey_conditional_questions -#: model:ir.model,name:survey_conditional_questions.model_survey_question -msgid "Survey Question" -msgstr "" - -#. module: survey_conditional_questions -#: model:ir.model,name:survey_conditional_questions.model_survey_user_input -msgid "Survey User Input" -msgstr "" - -#. module: survey_conditional_questions -#: view:website:survey.page -msgid "question.id not in hide_question_ids" -msgstr "" - diff --git a/survey_conditional_questions/models/__init__.py b/survey_conditional_questions/models/__init__.py deleted file mode 100644 index c18232d..0000000 --- a/survey_conditional_questions/models/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################## -# For copyright and license notices, see __manifest__.py file in module root -# directory -############################################################################## -from . import survey_question -from . import survey_user_input diff --git a/survey_conditional_questions/models/survey_question.py b/survey_conditional_questions/models/survey_question.py deleted file mode 100644 index 5aef5b9..0000000 --- a/survey_conditional_questions/models/survey_question.py +++ /dev/null @@ -1,58 +0,0 @@ -############################################################################## -# For copyright and license notices, see __manifest__.py file in module root -# directory -############################################################################## -from odoo import api, fields, models -import logging - -_logger = logging.getLogger(__name__) - - -class SurveyQuestion(models.Model): - _inherit = 'survey.question' - - conditional = fields.Boolean( - 'Conditional Question', - copy=False, - # we add copy = false to avoid wrong link on survey copy, - # should be improoved - ) - question_conditional_id = fields.Many2one( - 'survey.question', - 'Question', - copy=False, - domain="[('survey_id', '=', survey_id)]", - help="In order to edit this field you should" - " first save the question" - ) - answer_id = fields.Many2one( - 'survey.label', - 'Answer', - copy=False, - ) - - @api.multi - def validate_question(self, post, answer_tag): - ''' Validate question, depending on question - type and parameters ''' - self.ensure_one() - try: - checker = getattr(self, 'validate_' + self.type) - except AttributeError: - _logger.warning( - checker.type + - ": This type of question has no validation method") - return {} - else: - # TODO deberiamos emprolijar esto - if not self.question_conditional_id: - return checker(post, answer_tag) - input_answer_ids = self.env['survey.user_input_line'].search( - [('user_input_id.token', '=', post.get('token')), - ('question_id', '=', self.question_conditional_id.id)]) - for answers in input_answer_ids: - value_suggested = answers.value_suggested - if self.conditional and self.answer_id != value_suggested: - return {} - else: - return checker(post, answer_tag) diff --git a/survey_conditional_questions/models/survey_user_input.py b/survey_conditional_questions/models/survey_user_input.py deleted file mode 100644 index 413463f..0000000 --- a/survey_conditional_questions/models/survey_user_input.py +++ /dev/null @@ -1,28 +0,0 @@ -############################################################################## -# For copyright and license notices, see __manifest__.py file in module root -# directory -############################################################################## -from odoo import api, models - - -class SurveyUserInput(models.Model): - _inherit = 'survey.user_input' - - @api.model - def get_list_questions(self, survey, user_input): - obj_questions = self.env['survey.question'] - questions_to_hide = [] - question_ids = obj_questions.search( - [('survey_id', '=', survey.id)]) - for question in question_ids.filtered('conditional'): - for question2 in question_ids.filtered( - lambda x: x == question.question_conditional_id): - input_answer_ids = user_input.user_input_line_ids.filtered( - lambda x: x.question_id == question2) - should_hide = True - for answer in input_answer_ids: - if answer.value_suggested == question.answer_id: - should_hide = False - if should_hide: - questions_to_hide.append(question.id) - return questions_to_hide diff --git a/survey_conditional_questions/views/survey_question_qweb.xml b/survey_conditional_questions/views/survey_question_qweb.xml deleted file mode 100644 index 8201059..0000000 --- a/survey_conditional_questions/views/survey_question_qweb.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - diff --git a/survey_conditional_questions/views/survey_question_views.xml b/survey_conditional_questions/views/survey_question_views.xml deleted file mode 100644 index 3488b86..0000000 --- a/survey_conditional_questions/views/survey_question_views.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Form view for survey conditional question - survey.question - - - - - - - - - - - -