diff --git a/survey_custom_matrix/COPYRIGHT b/survey_custom_matrix/COPYRIGHT deleted file mode 100644 index 3143258..0000000 --- a/survey_custom_matrix/COPYRIGHT +++ /dev/null @@ -1,15 +0,0 @@ - -Most of the files are - - Copyright (c) 2012-TODAY Kanak Infosystems LLP - -Many files also contain contributions from third -parties. In this case the original copyright of -the contributions can be traced through the -history of the source version control system. - -When that is not the case, the files contain a prominent -notice stating the original copyright and applicable -license, or come with their own dedicated COPYRIGHT -and/or LICENSE file. - diff --git a/survey_custom_matrix/LICENSE b/survey_custom_matrix/LICENSE deleted file mode 100644 index d99face..0000000 --- a/survey_custom_matrix/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Kanak Infosystems LLP Proprietary License v1.0 - -This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Kanak Infosystems LLP Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). - -You may develop Kanak Infosystems LLP modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Kanak Infosystems LLP Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). - -It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. - -The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/survey_custom_matrix/__init__.py b/survey_custom_matrix/__init__.py index 7cdad7f..9e5827f 100644 --- a/survey_custom_matrix/__init__.py +++ b/survey_custom_matrix/__init__.py @@ -1,3 +1,3 @@ - -from . import models +# -*- coding: utf-8 -*- from . import controllers +from . import models diff --git a/survey_custom_matrix/__manifest__.py b/survey_custom_matrix/__manifest__.py index 3e1567e..56191a6 100644 --- a/survey_custom_matrix/__manifest__.py +++ b/survey_custom_matrix/__manifest__.py @@ -1,18 +1,5 @@ - -################################################################################# -# Author : Kanak Infosystems LLP. () -# Copyright(c): 2012-Present Kanak Infosystems LLP. -# All Rights Reserved. -# -# -# This program is copyright property of the author mentioned above. -# You can`t redistribute it and/or modify it. -# -# -# You should have received a copy of the License along with this program. -# If not, see -################################################################################# - +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': "Survey custom matrix", 'version': '1.0', @@ -36,6 +23,6 @@ Custom Matrix Survey. 'views/survey_user_input_line.xml', ], 'application': True, - 'price': 49, - 'currency': 'EUR', + # 'price': 49, + # 'currency': 'EUR', } diff --git a/survey_custom_matrix/controllers/__init__.py b/survey_custom_matrix/controllers/__init__.py index 12a7e52..757b12a 100644 --- a/survey_custom_matrix/controllers/__init__.py +++ b/survey_custom_matrix/controllers/__init__.py @@ -1 +1,2 @@ +# -*- coding: utf-8 -*- from . import main diff --git a/survey_custom_matrix/controllers/main.py b/survey_custom_matrix/controllers/main.py index 8579ba7..c78176a 100644 --- a/survey_custom_matrix/controllers/main.py +++ b/survey_custom_matrix/controllers/main.py @@ -1,15 +1,19 @@ - +# -*- coding: utf-8 -*- import json from odoo import http from odoo.http import request -import logging from odoo.addons.survey.controllers.main import Survey + +import logging _logger = logging.getLogger(__name__) + class Survey(Survey): - @http.route(['/survey/prefill//', - '/survey/prefill///'], - type='http', auth='public', website=True) + + @http.route([ + '/survey/prefill//', + '/survey/prefill///'], + type='http', auth='public', website=True) def prefill(self, survey, token, page=None, **post): UserInputLine = request.env['survey.user_input_line'] ret = {} @@ -23,7 +27,7 @@ class Survey(Survey): if not answer.skipped: answer_tag = '%s_%s_%s' % (answer.survey_id.id, answer.page_id.id, answer.question_id.id) answer_value = None - if answer.question_id.matrix_subtype == 'custom_row': + if answer.question_id.matrix_subtype == 'custom': if answer.answer_type == 'free_text': answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id) answer_value = answer.value_free_text @@ -38,7 +42,7 @@ class Survey(Survey): answer_value = answer.value_date elif answer.answer_type == 'dropdown': answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id) - answer_value = answer.value_dropdown.id + answer_value = answer.value_id.id elif answer.answer_type == 'suggestion' and not answer.value_suggested_row: answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id) answer_value = answer.value_suggested.id diff --git a/survey_custom_matrix/i18n/fr.po b/survey_custom_matrix/i18n/fr.po index a88ebdb..550615b 100644 --- a/survey_custom_matrix/i18n/fr.po +++ b/survey_custom_matrix/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-06 15:06+0000\n" -"PO-Revision-Date: 2020-04-06 15:06+0000\n" +"POT-Creation-Date: 2020-11-09 12:08+0000\n" +"PO-Revision-Date: 2020-11-09 12:08+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -36,12 +36,12 @@ msgid "Checkbox" msgstr "Case à cocher" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__create_uid +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__create_uid msgid "Created by" msgstr "Créé par" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__create_date +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__create_date msgid "Created on" msgstr "Créé le" @@ -53,10 +53,10 @@ msgstr "Matrice personnalisée" #. module: survey_custom_matrix #: selection:survey.user_input_line,answer_type:0 msgid "Date" -msgstr "Date" +msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__display_name +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__display_name msgid "Display Name" msgstr "Nom affiché" @@ -71,35 +71,31 @@ msgid "Free Text" msgstr "Texte libre" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__id +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__id msgid "ID" -msgstr "ID" +msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value____last_update +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value____last_update msgid "Last Modified on" msgstr "Dernière modification le" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__write_uid +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__write_uid msgid "Last Updated by" msgstr "Dernière mise à jour par" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__write_date +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__write_date msgid "Last Updated on" msgstr "Dernière mise à jour le" #. module: survey_custom_matrix #: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_question__matrix_subtype +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__matrix_subtype msgid "Matrix Type" msgstr "Type de matrice" -#. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__matrix_subtype_id -msgid "Matrix subtype" -msgstr "Sous-type de matrice" - #. module: survey_custom_matrix #: selection:survey.label,type:0 msgid "Multiple Lines Text Box" @@ -111,7 +107,7 @@ msgid "Multiple choices per row" msgstr "Plusieurs choix par ligne" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__name +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__name msgid "Name" msgstr "Nom" @@ -131,7 +127,7 @@ msgid "One choice per row" msgstr "Un choix par ligne" #. module: survey_custom_matrix -#: model_terms:ir.ui.view,arch_db:survey_custom_matrix.survey_user_input_custom_form +#: model_terms:ir.ui.view,arch_db:survey_custom_matrix.survey_user_input_form msgid "Print PDF Answers" msgstr "Imprimer les réponses en PDF" @@ -143,7 +139,7 @@ msgstr "Ligne de texte unique" #. module: survey_custom_matrix #: selection:survey.user_input_line,answer_type:0 msgid "Suggestion" -msgstr "Suggestion" +msgstr "" #. module: survey_custom_matrix #: model:ir.model,name:survey_custom_matrix.model_survey_label @@ -167,20 +163,20 @@ msgstr "Texte" #. module: survey_custom_matrix #: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label__type -msgid "Type of Question" +msgid "Type of question" msgstr "Type de question" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__value_dropdown -msgid "Value Dropdown" -msgstr "Valeur possible" +#: model:ir.model,name:survey_custom_matrix.model_survey_label_value +msgid "Value" +msgstr "Valeur" #. module: survey_custom_matrix -#: model:ir.model,name:survey_custom_matrix.model_dp_attributes_value -msgid "survey.label.value" -msgstr "" +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__value_id +msgid "Value Dropdown" +msgstr "Valeur" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label__dpvalues -msgid "values" +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label__value_ids +msgid "Values" msgstr "Valeurs" diff --git a/survey_custom_matrix/i18n/custom_matrix_survey.pot b/survey_custom_matrix/i18n/survey_custom_matrix.pot similarity index 85% rename from survey_custom_matrix/i18n/custom_matrix_survey.pot rename to survey_custom_matrix/i18n/survey_custom_matrix.pot index 7079e7f..dcb4ab7 100644 --- a/survey_custom_matrix/i18n/custom_matrix_survey.pot +++ b/survey_custom_matrix/i18n/survey_custom_matrix.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0+e\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-06 15:07+0000\n" -"PO-Revision-Date: 2020-04-06 15:07+0000\n" +"POT-Creation-Date: 2020-11-09 12:09+0000\n" +"PO-Revision-Date: 2020-11-09 12:09+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -36,12 +36,12 @@ msgid "Checkbox" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__create_uid +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__create_uid msgid "Created by" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__create_date +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__create_date msgid "Created on" msgstr "" @@ -56,7 +56,7 @@ msgid "Date" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__display_name +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__display_name msgid "Display Name" msgstr "" @@ -71,35 +71,31 @@ msgid "Free Text" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__id +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__id msgid "ID" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value____last_update +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value____last_update msgid "Last Modified on" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__write_uid +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__write_uid msgid "Last Updated by" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__write_date +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__write_date msgid "Last Updated on" msgstr "" #. module: survey_custom_matrix #: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_question__matrix_subtype +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__matrix_subtype msgid "Matrix Type" msgstr "" -#. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__matrix_subtype_id -msgid "Matrix subtype" -msgstr "" - #. module: survey_custom_matrix #: selection:survey.label,type:0 msgid "Multiple Lines Text Box" @@ -111,7 +107,7 @@ msgid "Multiple choices per row" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_dp_attributes_value__name +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label_value__name msgid "Name" msgstr "" @@ -131,7 +127,7 @@ msgid "One choice per row" msgstr "" #. module: survey_custom_matrix -#: model_terms:ir.ui.view,arch_db:survey_custom_matrix.survey_user_input_custom_form +#: model_terms:ir.ui.view,arch_db:survey_custom_matrix.survey_user_input_form msgid "Print PDF Answers" msgstr "" @@ -167,21 +163,20 @@ msgstr "" #. module: survey_custom_matrix #: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label__type -msgid "Type of Question" +msgid "Type of question" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__value_dropdown -msgid "Value Dropdown" +#: model:ir.model,name:survey_custom_matrix.model_survey_label_value +msgid "Value" msgstr "" #. module: survey_custom_matrix -#: model:ir.model,name:survey_custom_matrix.model_dp_attributes_value -msgid "survey.label.value" +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_user_input_line__value_id +msgid "Value Dropdown" msgstr "" #. module: survey_custom_matrix -#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label__dpvalues -msgid "values" +#: model:ir.model.fields,field_description:survey_custom_matrix.field_survey_label__value_ids +msgid "Values" msgstr "" - diff --git a/survey_custom_matrix/models/__init__.py b/survey_custom_matrix/models/__init__.py index 256bcc3..3e7ddbb 100644 --- a/survey_custom_matrix/models/__init__.py +++ b/survey_custom_matrix/models/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import survey_label from . import survey_label_value from . import survey_question diff --git a/survey_custom_matrix/models/survey_label.py b/survey_custom_matrix/models/survey_label.py index 874707c..cf54499 100644 --- a/survey_custom_matrix/models/survey_label.py +++ b/survey_custom_matrix/models/survey_label.py @@ -1,16 +1,18 @@ - -from odoo import models, fields, _ +# -*- coding: utf-8 -*- +from odoo import models, fields TYPES = [ - ('free_text', _('Multiple Lines Text Box')), - ('textbox', _('Single Line Text Box')), - ('numerical_box', _('Numerical Value')), - ('dropdown', _('Dropdown')), - ('checkbox', _('Checkbox')), + ('free_text', 'Multiple Lines Text Box'), + ('textbox', 'Single Line Text Box'), + ('numerical_box', 'Numerical Value'), + # ('date', 'Date'), + ('dropdown', 'Dropdown'), + ('checkbox', 'Checkbox'), ] + class SurveyLabel(models.Model): _inherit = 'survey.label' - type = fields.Selection(selection=TYPES, string='Type of Question', default="checkbox") - dpvalues = fields.Many2many(comodel_name='survey.label.value', string="values") + type = fields.Selection(selection=TYPES, string="Type of question", default="checkbox") + value_ids = fields.Many2many(comodel_name='survey.label.value', string="Values") diff --git a/survey_custom_matrix/models/survey_label_value.py b/survey_custom_matrix/models/survey_label_value.py index a8c3653..796eea0 100644 --- a/survey_custom_matrix/models/survey_label_value.py +++ b/survey_custom_matrix/models/survey_label_value.py @@ -1,8 +1,9 @@ +# -*- coding: utf-8 -*- from odoo import models, fields class SurveyLabelValue(models.Model): _name = 'survey.label.value' - _description = "Valeur" + _description = "Value" - name = fields.Char(strring="Name") + name = fields.Char(string="Name") diff --git a/survey_custom_matrix/models/survey_question.py b/survey_custom_matrix/models/survey_question.py index ce6cd31..08eae02 100644 --- a/survey_custom_matrix/models/survey_question.py +++ b/survey_custom_matrix/models/survey_question.py @@ -1,18 +1,12 @@ +# -*- coding: utf-8 -*- from odoo import api, fields, models - -def dict_keys_startswith(dictionary, string): - """Returns a dictionary containing the elements of whose keys start with . - .. note:: - This function uses dictionary comprehensions (Python >= 2.7) - """ - return {k: v for k, v in dictionary.items() if k.startswith(string)} +from odoo.addons.survey.models.survey import dict_keys_startswith class SurveyQuestion(models.Model): _inherit = 'survey.question' - matrix_subtype = fields.Selection([('simple', 'One choice per row'), - ('multiple', 'Multiple choices per row'), ('custom_row', 'Custom Matrix')], string='Matrix Type', default='simple') + matrix_subtype = fields.Selection(selection_add=[('custom', 'Custom Matrix')]) @api.multi def validate_matrix(self, post, answer_tag): @@ -27,7 +21,7 @@ class SurveyQuestion(models.Model): answer_number = len(answer_candidates) elif self.matrix_subtype == 'multiple': answer_number = len({sk.rsplit('_', 1)[0] for sk in answer_candidates}) - elif self.matrix_subtype == 'custom_row': + elif self.matrix_subtype == 'custom': answer_number = len({sk.rsplit('_', 1)[0] for sk in answer_candidates}) else: raise RuntimeError("Invalid matrix subtype") @@ -35,84 +29,3 @@ class SurveyQuestion(models.Model): if answer_number != lines_number: errors.update({answer_tag: self.constr_error_msg}) return errors - -class SurveyUserInputLine(models.Model): - _inherit = 'survey.user_input_line' - - answer_type = fields.Selection([ - ('text', 'Text'), - ('number', 'Number'), - ('date', 'Date'), - ('free_text', 'Free Text'), - ('suggestion', 'Suggestion'), ('dropdown', 'Dropdown')], string='Answer Type') - - value_dropdown = fields.Many2one('survey.label.value', string="Value Dropdown") - matrix_subtype_id = fields.Selection(related='question_id.matrix_subtype', string="Matrix subtype") - - @api.model - def save_line_matrix(self, user_input_id, question, post, answer_tag): - vals = { - 'user_input_id': user_input_id, - 'question_id': question.id, - 'survey_id': question.survey_id.id, - 'skipped': False - } - old_uil = self.search([ - ('user_input_id', '=', user_input_id), - ('survey_id', '=', question.survey_id.id), - ('question_id', '=', question.id) - ]) - old_uil.sudo().unlink() - - no_answers = True - ca_dict = dict_keys_startswith(post, answer_tag + '_') - - comment_answer = ca_dict.pop(("%s_%s" % (answer_tag, 'comment')), '').strip() - if comment_answer: - vals.update({'answer_type': 'text', 'value_text': comment_answer}) - self.create(vals) - no_answers = False - - if question.matrix_subtype == 'simple': - for row in question.labels_ids_2: - a_tag = "%s_%s" % (answer_tag, row.id) - if a_tag in ca_dict: - no_answers = False - vals.update({'answer_type': 'suggestion', 'value_suggested': ca_dict[a_tag], 'value_suggested_row': row.id}) - self.create(vals) - - elif question.matrix_subtype == 'multiple': - for col in question.labels_ids: - for row in question.labels_ids_2: - a_tag = "%s_%s_%s" % (answer_tag, row.id, col.id) - if a_tag in ca_dict: - no_answers = False - vals.update({'answer_type': 'suggestion', 'value_suggested': col.id, 'value_suggested_row': row.id}) - self.create(vals) - elif question.matrix_subtype == 'custom_row': - for col in question.labels_ids: - for row in question.labels_ids_2: - a_tag = "%s_%s_%s" % (answer_tag, row.id, col.id) - if a_tag in ca_dict: - no_answers = False - if post.get(a_tag): - sline = a_tag.split('_')[-1] - label_obj = question.labels_ids.browse(int(sline)) - if label_obj.type == 'textbox': - vals.update({'answer_type': 'text', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_text': post.get(a_tag)}) - elif label_obj.type == 'free_text': - vals.update({'answer_type': 'free_text', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_free_text': post.get(a_tag)}) - elif label_obj.type == 'numerical_box': - vals.update({'answer_type': 'number', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_number': post.get(a_tag)}) - elif label_obj.type == 'date': - vals.update({'answer_type': 'date', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_date': post.get(a_tag)}) - elif label_obj.type == 'dropdown': - vals.update({'answer_type': 'dropdown', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_dropdown': int(post.get(a_tag))}) - else: - vals.update({'answer_type': 'suggestion', 'value_suggested': col.id, 'value_suggested_row': row.id}) - self.create(vals) - - if no_answers: - vals.update({'answer_type': None, 'skipped': True}) - self.create(vals) - return True diff --git a/survey_custom_matrix/models/survey_user_input_line.py b/survey_custom_matrix/models/survey_user_input_line.py index e0f2427..ebe13b5 100644 --- a/survey_custom_matrix/models/survey_user_input_line.py +++ b/survey_custom_matrix/models/survey_user_input_line.py @@ -1,25 +1,14 @@ +# -*- coding: utf-8 -*- from odoo import models, fields, api - -def dict_keys_startswith(dictionary, string): - """Returns a dictionary containing the elements of whose keys start with . - .. note:: - This function uses dictionary comprehensions (Python >= 2.7) - """ - return {k: v for k, v in dictionary.items() if k.startswith(string)} +from odoo.addons.survey.models.survey import dict_keys_startswith class SurveyUserInputLine(models.Model): _inherit = 'survey.user_input_line' - answer_type = fields.Selection([ - ('text', 'Text'), - ('number', 'Number'), - ('date', 'Date'), - ('free_text', 'Free Text'), - ('suggestion', 'Suggestion'), ('dropdown', 'Dropdown')], string='Answer Type') - - value_dropdown = fields.Many2one('survey.label.value', string="Value Dropdown") - matrix_subtype_id = fields.Selection(related='question_id.matrix_subtype', string="Matrix subtype") + answer_type = fields.Selection(selection_add=[('dropdown', 'Dropdown')], string='Answer Type') + matrix_subtype = fields.Selection(related='question_id.matrix_subtype') + value_id = fields.Many2one('survey.label.value', string="Value Dropdown") @api.model def save_line_matrix(self, user_input_id, question, post, answer_tag): @@ -29,19 +18,22 @@ class SurveyUserInputLine(models.Model): 'survey_id': question.survey_id.id, 'skipped': False } - old_uil = self.search([ + suil = self.search([ ('user_input_id', '=', user_input_id), ('survey_id', '=', question.survey_id.id), ('question_id', '=', question.id) ]) - old_uil.sudo().unlink() + suil.sudo().unlink() no_answers = True ca_dict = dict_keys_startswith(post, answer_tag + '_') comment_answer = ca_dict.pop(("%s_%s" % (answer_tag, 'comment')), '').strip() if comment_answer: - vals.update({'answer_type': 'text', 'value_text': comment_answer}) + vals.update({ + 'answer_type': 'text', + 'value_text': comment_answer, + }) self.create(vals) no_answers = False @@ -50,7 +42,11 @@ class SurveyUserInputLine(models.Model): a_tag = "%s_%s" % (answer_tag, row.id) if a_tag in ca_dict: no_answers = False - vals.update({'answer_type': 'suggestion', 'value_suggested': ca_dict[a_tag], 'value_suggested_row': row.id}) + vals.update({ + 'answer_type': 'suggestion', + 'value_suggested': ca_dict[a_tag], + 'value_suggested_row': row.id, + }) self.create(vals) elif question.matrix_subtype == 'multiple': @@ -59,10 +55,14 @@ class SurveyUserInputLine(models.Model): a_tag = "%s_%s_%s" % (answer_tag, row.id, col.id) if a_tag in ca_dict: no_answers = False - vals.update({'answer_type': 'suggestion', 'value_suggested': col.id, 'value_suggested_row': row.id}) + vals.update({ + 'answer_type': 'suggestion', + 'value_suggested': col.id, + 'value_suggested_row': row.id, + }) self.create(vals) - elif question.matrix_subtype == 'custom_row': + elif question.matrix_subtype == 'custom': for col in question.labels_ids: for row in question.labels_ids_2: a_tag = "%s_%s_%s" % (answer_tag, row.id, col.id) @@ -72,20 +72,51 @@ class SurveyUserInputLine(models.Model): sline = a_tag.split('_')[-1] label_obj = question.labels_ids.browse(int(sline)) if label_obj.type == 'textbox': - vals.update({'answer_type': 'text', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_text': post.get(a_tag)}) + vals.update({ + 'answer_type': 'text', + 'value_suggested': col.id, + 'value_suggested_row': row.id, + 'value_text': post.get(a_tag), + }) elif label_obj.type == 'free_text': - vals.update({'answer_type': 'free_text', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_free_text': post.get(a_tag)}) + vals.update({ + 'answer_type': 'free_text', + 'value_suggested': col.id, + 'value_suggested_row': row.id, + 'value_free_text': post.get(a_tag), + }) elif label_obj.type == 'numerical_box': - vals.update({'answer_type': 'number', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_number': post.get(a_tag)}) + vals.update({ + 'answer_type': 'number', + 'value_suggested': col.id, + 'value_suggested_row': row.id, + 'value_number': post.get(a_tag), + }) elif label_obj.type == 'date': - vals.update({'answer_type': 'date', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_date': post.get(a_tag)}) + vals.update({ + 'answer_type': 'date', + 'value_suggested': col.id, + 'value_suggested_row': row.id, + 'value_date': post.get(a_tag), + }) elif label_obj.type == 'dropdown': - vals.update({'answer_type': 'dropdown', 'value_suggested': col.id, 'value_suggested_row': row.id, 'value_dropdown': int(post.get(a_tag))}) + vals.update({ + 'answer_type': 'dropdown', + 'value_suggested': col.id, + 'value_suggested_row': row.id, + 'value_id': int(post.get(a_tag)), + }) else: - vals.update({'answer_type': 'suggestion', 'value_suggested': col.id, 'value_suggested_row': row.id}) + vals.update({ + 'answer_type': 'suggestion', + 'value_suggested': col.id, + 'value_suggested_row': row.id}) self.create(vals) if no_answers: - vals.update({'answer_type': None, 'skipped': True}) + vals.update({ + 'answer_type': None, + 'skipped': True, + }) self.create(vals) return True diff --git a/survey_custom_matrix/reports/user_input.xml b/survey_custom_matrix/reports/user_input.xml index d4f2fff..a6afced 100644 --- a/survey_custom_matrix/reports/user_input.xml +++ b/survey_custom_matrix/reports/user_input.xml @@ -11,7 +11,7 @@ - +

@@ -45,7 +45,7 @@ - + diff --git a/survey_custom_matrix/security/ir_model_access.xml b/survey_custom_matrix/security/ir_model_access.xml index b375368..f965581 100644 --- a/survey_custom_matrix/security/ir_model_access.xml +++ b/survey_custom_matrix/security/ir_model_access.xml @@ -1,7 +1,7 @@ - - survey.label.value All R + + survey.label.value All 1 0 @@ -9,8 +9,8 @@ 0 - - survey.label.value Survey Manager RWCU + + survey.label.value Survey Manager 1 diff --git a/survey_custom_matrix/static/description/banner.jpg b/survey_custom_matrix/static/description/banner.jpg deleted file mode 100644 index 8177cdb..0000000 Binary files a/survey_custom_matrix/static/description/banner.jpg and /dev/null differ diff --git a/survey_custom_matrix/static/description/call-icon.png b/survey_custom_matrix/static/description/call-icon.png deleted file mode 100644 index 14f116d..0000000 Binary files a/survey_custom_matrix/static/description/call-icon.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/color code.txt b/survey_custom_matrix/static/description/color code.txt deleted file mode 100644 index 4d68dc8..0000000 --- a/survey_custom_matrix/static/description/color code.txt +++ /dev/null @@ -1,2 +0,0 @@ -Blue color: 123246 -Red Color: dc1d1d \ No newline at end of file diff --git a/survey_custom_matrix/static/description/features-icon.png b/survey_custom_matrix/static/description/features-icon.png deleted file mode 100644 index 8d6b2f7..0000000 Binary files a/survey_custom_matrix/static/description/features-icon.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon-2.png b/survey_custom_matrix/static/description/icon-2.png deleted file mode 100644 index 447419b..0000000 Binary files a/survey_custom_matrix/static/description/icon-2.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon-3.png b/survey_custom_matrix/static/description/icon-3.png deleted file mode 100644 index 87af289..0000000 Binary files a/survey_custom_matrix/static/description/icon-3.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon-4.png b/survey_custom_matrix/static/description/icon-4.png deleted file mode 100644 index a3340a7..0000000 Binary files a/survey_custom_matrix/static/description/icon-4.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon-5.png b/survey_custom_matrix/static/description/icon-5.png deleted file mode 100644 index 65d77bd..0000000 Binary files a/survey_custom_matrix/static/description/icon-5.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon-6.png b/survey_custom_matrix/static/description/icon-6.png deleted file mode 100644 index 7a1044f..0000000 Binary files a/survey_custom_matrix/static/description/icon-6.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon.png b/survey_custom_matrix/static/description/icon.png deleted file mode 100644 index b27344b..0000000 Binary files a/survey_custom_matrix/static/description/icon.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/icon1.png b/survey_custom_matrix/static/description/icon1.png deleted file mode 100644 index 00b2c78..0000000 Binary files a/survey_custom_matrix/static/description/icon1.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/index.html b/survey_custom_matrix/static/description/index.html deleted file mode 100644 index eb284b6..0000000 --- a/survey_custom_matrix/static/description/index.html +++ /dev/null @@ -1,248 +0,0 @@ -
-
-
-

- Matrix Survey -

-
-
-
-
-
-
-

Create Survey & Add Survey pages

-
-
-
-
- -
-
-
-
-
-
-
-
-

Add questions for survey page

-
-
- -
-
-
-
-
-
-
-
-

Set question type as "matrix"

-
-
- -
-
-
-
-
-
-
-
-

Set type of matrix

-
-
- -
-
-
-
-
-
-
-
-

- Add answer's choices & Set display type of questions
- with different types of input methods -

-
-
- -
-
-
-
-
-
-
-
-

Add multiple header rows

-
-
- -
-
-
-
-
-
-
-
-

Fill survey

-
-
- -
-
-
-
-
-
-
-
-

View filled answers of survey

-
-
- -
-
-
-
-
-
-
-
-

Get print in .pdf

-
-
- -
-
-
-
-
-
-
-
-

PDF view

-
-
- -
-
-
-
-
-
-
-
-

Print filled answers

-
-
- -
-
-
-
-
-
-
-
-

Filled Answers

-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
- -
-
"We are groupies wrapped in Creativity, Skills and Innovation"
-

We are authorized IT company to offer advanced, hight quality and affordable IT solutions. We have years of rich experience in the field of ODOO Development, ERP Solutions, Web Development, Mobile Apps, Web Designing and Digital marketing. Around a decade are offering quality assured and 100% customer satisfaction services to global clientele.

- -

Our highly experienced and devoted team of professionals works with there heart, passion and talent to provide the most dedicated IT Business Solutions to our valuable clients globally. Our team works on the real words "Dedication,"Timely Deliverables",And "Happy Clients"!

-
-
-
-
-

What We Do

-
-
-
-
- -
Odoo Customization
-
-
- -
Odoo Code Migration
-
-
- -
Odoo Mobile App
-
-
- -
Odoo DB Migration
-
-
- -
Odoo Web Development
-
-
- -
Odoo Themes
-
-
- -
- -
-
-
- - Help -
-
- - Support -
-
- - Request New Features -
-
-
-
-
-
-
diff --git a/survey_custom_matrix/static/description/logo.png b/survey_custom_matrix/static/description/logo.png deleted file mode 100644 index 78fdb08..0000000 Binary files a/survey_custom_matrix/static/description/logo.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/main_image.jpg b/survey_custom_matrix/static/description/main_image.jpg deleted file mode 100755 index 5b48b41..0000000 Binary files a/survey_custom_matrix/static/description/main_image.jpg and /dev/null differ diff --git a/survey_custom_matrix/static/description/support-icon.png b/survey_custom_matrix/static/description/support-icon.png deleted file mode 100644 index c169f79..0000000 Binary files a/survey_custom_matrix/static/description/support-icon.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_1.png b/survey_custom_matrix/static/description/survey_1.png deleted file mode 100644 index 0816ad9..0000000 Binary files a/survey_custom_matrix/static/description/survey_1.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_10.png b/survey_custom_matrix/static/description/survey_10.png deleted file mode 100644 index ca397ef..0000000 Binary files a/survey_custom_matrix/static/description/survey_10.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_11.png b/survey_custom_matrix/static/description/survey_11.png deleted file mode 100644 index 901a3e1..0000000 Binary files a/survey_custom_matrix/static/description/survey_11.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_12.png b/survey_custom_matrix/static/description/survey_12.png deleted file mode 100644 index 0d58894..0000000 Binary files a/survey_custom_matrix/static/description/survey_12.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_13.png b/survey_custom_matrix/static/description/survey_13.png deleted file mode 100644 index 46e65fb..0000000 Binary files a/survey_custom_matrix/static/description/survey_13.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_2.png b/survey_custom_matrix/static/description/survey_2.png deleted file mode 100644 index b79280c..0000000 Binary files a/survey_custom_matrix/static/description/survey_2.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_3.png b/survey_custom_matrix/static/description/survey_3.png deleted file mode 100644 index 1c37524..0000000 Binary files a/survey_custom_matrix/static/description/survey_3.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_4.png b/survey_custom_matrix/static/description/survey_4.png deleted file mode 100644 index d7d1f16..0000000 Binary files a/survey_custom_matrix/static/description/survey_4.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_5.png b/survey_custom_matrix/static/description/survey_5.png deleted file mode 100644 index b079065..0000000 Binary files a/survey_custom_matrix/static/description/survey_5.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_6.png b/survey_custom_matrix/static/description/survey_6.png deleted file mode 100644 index a50a096..0000000 Binary files a/survey_custom_matrix/static/description/survey_6.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_8.png b/survey_custom_matrix/static/description/survey_8.png deleted file mode 100644 index 12633c9..0000000 Binary files a/survey_custom_matrix/static/description/survey_8.png and /dev/null differ diff --git a/survey_custom_matrix/static/description/survey_9.png b/survey_custom_matrix/static/description/survey_9.png deleted file mode 100644 index df36c99..0000000 Binary files a/survey_custom_matrix/static/description/survey_9.png and /dev/null differ diff --git a/survey_custom_matrix/templates/matrix.xml b/survey_custom_matrix/templates/matrix.xml index 6ba5a61..bcf38d5 100644 --- a/survey_custom_matrix/templates/matrix.xml +++ b/survey_custom_matrix/templates/matrix.xml @@ -15,34 +15,25 @@
diff --git a/survey_custom_matrix/views/survey_question.xml b/survey_custom_matrix/views/survey_question.xml index b9d6772..33e4fd8 100644 --- a/survey_custom_matrix/views/survey_question.xml +++ b/survey_custom_matrix/views/survey_question.xml @@ -8,7 +8,7 @@ - + diff --git a/survey_custom_matrix/views/survey_user_input_line.xml b/survey_custom_matrix/views/survey_user_input_line.xml index 1c2cd09..00b70e5 100644 --- a/survey_custom_matrix/views/survey_user_input_line.xml +++ b/survey_custom_matrix/views/survey_user_input_line.xml @@ -7,11 +7,11 @@ - - + + - +
- - - - - - - - - - - -
- + + + + + + + + -