From 66dc339f653e2907e5d6af54a70e33b9957528b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20FRAN=C3=87OIS?= Date: Mon, 20 Apr 2020 18:34:52 +0200 Subject: [PATCH] [REF] custom_matrix_survey --- custom_matrix_survey/__init__.py | 2 +- custom_matrix_survey/__manifest__.py | 11 +- custom_matrix_survey/controllers/__init__.py | 2 - custom_matrix_survey/controllers/main.py | 4 +- .../i18n/custom_matrix_survey.pot | 187 ++++++++++++++++++ custom_matrix_survey/i18n/fr.po | 186 +++++++++++++++++ custom_matrix_survey/models/__init__.py | 5 +- custom_matrix_survey/models/survey_label.py | 16 ++ .../models/survey_label_value.py | 8 + .../models/{survey.py => survey_question.py} | 30 +-- .../models/survey_user_input_line.py | 91 +++++++++ custom_matrix_survey/reports/user_input.xml | 88 +++++++++ .../security/ir.model.access.csv | 2 - .../security/ir_model_access.xml | 22 +++ custom_matrix_survey/static/src/js/custom.js | 7 - custom_matrix_survey/templates/matrix.xml | 53 +++++ custom_matrix_survey/views/assets.xml | 11 -- custom_matrix_survey/views/custom_survey.xml | 127 ------------ .../views/survey_question.xml | 16 ++ .../views/survey_user_input.xml | 15 ++ .../views/survey_user_input_line.xml | 19 ++ custom_matrix_survey/views/survey_views.xml | 49 ----- 22 files changed, 720 insertions(+), 231 deletions(-) create mode 100644 custom_matrix_survey/i18n/custom_matrix_survey.pot create mode 100644 custom_matrix_survey/i18n/fr.po create mode 100644 custom_matrix_survey/models/survey_label.py create mode 100644 custom_matrix_survey/models/survey_label_value.py rename custom_matrix_survey/models/{survey.py => survey_question.py} (87%) create mode 100644 custom_matrix_survey/models/survey_user_input_line.py create mode 100644 custom_matrix_survey/reports/user_input.xml delete mode 100644 custom_matrix_survey/security/ir.model.access.csv create mode 100644 custom_matrix_survey/security/ir_model_access.xml delete mode 100644 custom_matrix_survey/static/src/js/custom.js create mode 100644 custom_matrix_survey/templates/matrix.xml delete mode 100644 custom_matrix_survey/views/assets.xml delete mode 100644 custom_matrix_survey/views/custom_survey.xml create mode 100644 custom_matrix_survey/views/survey_question.xml create mode 100644 custom_matrix_survey/views/survey_user_input.xml create mode 100644 custom_matrix_survey/views/survey_user_input_line.xml delete mode 100644 custom_matrix_survey/views/survey_views.xml diff --git a/custom_matrix_survey/__init__.py b/custom_matrix_survey/__init__.py index 3b38916..7cdad7f 100644 --- a/custom_matrix_survey/__init__.py +++ b/custom_matrix_survey/__init__.py @@ -1,3 +1,3 @@ -# -*- coding: utf-8 -*- + from . import models from . import controllers diff --git a/custom_matrix_survey/__manifest__.py b/custom_matrix_survey/__manifest__.py index 6580325..e96f3a0 100644 --- a/custom_matrix_survey/__manifest__.py +++ b/custom_matrix_survey/__manifest__.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + ################################################################################# # Author : Kanak Infosystems LLP. () # Copyright(c): 2012-Present Kanak Infosystems LLP. @@ -28,9 +28,12 @@ Custom Matrix Survey. 'category': 'Website', 'depends': ['survey'], 'data': [ - 'security/ir.model.access.csv', - 'views/survey_views.xml', - 'views/custom_survey.xml', + 'security/ir_model_access.xml', + 'templates/matrix.xml', + 'reports/user_input.xml', + 'views/survey_question.xml', + 'views/survey_user_input.xml', + 'views/survey_user_input_line.xml', ], 'application': True, 'price': 49, diff --git a/custom_matrix_survey/controllers/__init__.py b/custom_matrix_survey/controllers/__init__.py index 65a8c12..12a7e52 100644 --- a/custom_matrix_survey/controllers/__init__.py +++ b/custom_matrix_survey/controllers/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import main diff --git a/custom_matrix_survey/controllers/main.py b/custom_matrix_survey/controllers/main.py index 5f852c1..8579ba7 100644 --- a/custom_matrix_survey/controllers/main.py +++ b/custom_matrix_survey/controllers/main.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + import json from odoo import http from odoo.http import request @@ -71,4 +71,4 @@ class Survey(Survey): ret.setdefault(answer_tag, []).append(answer_value) else: _logger.warning("[survey] No answer has been found for question %s marked as non skipped" % answer_tag) - return json.dumps(ret) \ No newline at end of file + return json.dumps(ret) diff --git a/custom_matrix_survey/i18n/custom_matrix_survey.pot b/custom_matrix_survey/i18n/custom_matrix_survey.pot new file mode 100644 index 0000000..3bbb3d5 --- /dev/null +++ b/custom_matrix_survey/i18n/custom_matrix_survey.pot @@ -0,0 +1,187 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * custom_matrix_survey +# +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" +"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: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_user_input_line__answer_type +msgid "Answer Type" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.actions.report,name:custom_matrix_survey.action_view_pdf_answers +msgid "Answers" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Attachment" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Checkbox" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__create_uid +msgid "Created by" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__create_date +msgid "Created on" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.question,matrix_subtype:0 +msgid "Custom Matrix" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Date" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__display_name +msgid "Display Name" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Dropdown" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Free Text" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__id +msgid "ID" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value____last_update +msgid "Last Modified on" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__write_date +msgid "Last Updated on" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_question__matrix_subtype +msgid "Matrix Type" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_user_input_line__matrix_subtype_id +msgid "Matrix subtype" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Multiple Lines Text Box" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.question,matrix_subtype:0 +msgid "Multiple choices per row" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__name +msgid "Name" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Number" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Numerical Value" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.question,matrix_subtype:0 +msgid "One choice per row" +msgstr "" + +#. module: custom_matrix_survey +#: model_terms:ir.ui.view,arch_db:custom_matrix_survey.survey_user_input_custom_form +msgid "Print PDF Answers" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Single Line Text Box" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Suggestion" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_survey_label +msgid "Survey Label" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_survey_question +msgid "Survey Question" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_survey_user_input_line +msgid "Survey User Input Line" +msgstr "" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Text" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_label__type +msgid "Type of Question" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_user_input_line__value_dropdown +msgid "Value Dropdown" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_dp_attributes_value +msgid "survey.label.value" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_label__dpvalues +msgid "values" +msgstr "" + diff --git a/custom_matrix_survey/i18n/fr.po b/custom_matrix_survey/i18n/fr.po new file mode 100644 index 0000000..a0e0870 --- /dev/null +++ b/custom_matrix_survey/i18n/fr.po @@ -0,0 +1,186 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * custom_matrix_survey +# +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" +"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: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_user_input_line__answer_type +msgid "Answer Type" +msgstr "Type de réponse" + +#. module: custom_matrix_survey +#: model:ir.actions.report,name:custom_matrix_survey.action_view_pdf_answers +msgid "Answers" +msgstr "Réponses" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Attachment" +msgstr "Pièce jointe" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Checkbox" +msgstr "Case à cocher" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: custom_matrix_survey +#: selection:survey.question,matrix_subtype:0 +msgid "Custom Matrix" +msgstr "Matrice personnalisée" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Date" +msgstr "Date" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Dropdown" +msgstr "Liste déroulante" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Free Text" +msgstr "Texte libre" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__id +msgid "ID" +msgstr "ID" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_question__matrix_subtype +msgid "Matrix Type" +msgstr "Type de matrice" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_user_input_line__matrix_subtype_id +msgid "Matrix subtype" +msgstr "Sous-type de matrice" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Multiple Lines Text Box" +msgstr "Plusieurs lignes de texte" + +#. module: custom_matrix_survey +#: selection:survey.question,matrix_subtype:0 +msgid "Multiple choices per row" +msgstr "Plusieurs choix par ligne" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_dp_attributes_value__name +msgid "Name" +msgstr "Nom" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Number" +msgstr "Numéro" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Numerical Value" +msgstr "Valeur numérique" + +#. module: custom_matrix_survey +#: selection:survey.question,matrix_subtype:0 +msgid "One choice per row" +msgstr "Un choix par ligne" + +#. module: custom_matrix_survey +#: model_terms:ir.ui.view,arch_db:custom_matrix_survey.survey_user_input_custom_form +msgid "Print PDF Answers" +msgstr "Imprimer les réponses en PDF" + +#. module: custom_matrix_survey +#: selection:survey.label,type:0 +msgid "Single Line Text Box" +msgstr "Ligne de texte unique" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Suggestion" +msgstr "Suggestion" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_survey_label +msgid "Survey Label" +msgstr "Étiquette du sondage" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_survey_question +msgid "Survey Question" +msgstr "Question du sondage" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_survey_user_input_line +msgid "Survey User Input Line" +msgstr "Ligne de saisie pour l'utilisateur du sondage" + +#. module: custom_matrix_survey +#: selection:survey.user_input_line,answer_type:0 +msgid "Text" +msgstr "Texte" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_label__type +msgid "Type of Question" +msgstr "Type de question" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_user_input_line__value_dropdown +msgid "Value Dropdown" +msgstr "Valeur possible" + +#. module: custom_matrix_survey +#: model:ir.model,name:custom_matrix_survey.model_dp_attributes_value +msgid "survey.label.value" +msgstr "" + +#. module: custom_matrix_survey +#: model:ir.model.fields,field_description:custom_matrix_survey.field_survey_label__dpvalues +msgid "values" +msgstr "Valeurs" diff --git a/custom_matrix_survey/models/__init__.py b/custom_matrix_survey/models/__init__.py index 7e49d37..256bcc3 100644 --- a/custom_matrix_survey/models/__init__.py +++ b/custom_matrix_survey/models/__init__.py @@ -1 +1,4 @@ -from . import survey +from . import survey_label +from . import survey_label_value +from . import survey_question +from . import survey_user_input_line diff --git a/custom_matrix_survey/models/survey_label.py b/custom_matrix_survey/models/survey_label.py new file mode 100644 index 0000000..874707c --- /dev/null +++ b/custom_matrix_survey/models/survey_label.py @@ -0,0 +1,16 @@ + +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')), +] + +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") diff --git a/custom_matrix_survey/models/survey_label_value.py b/custom_matrix_survey/models/survey_label_value.py new file mode 100644 index 0000000..a8c3653 --- /dev/null +++ b/custom_matrix_survey/models/survey_label_value.py @@ -0,0 +1,8 @@ +from odoo import models, fields + + +class SurveyLabelValue(models.Model): + _name = 'survey.label.value' + _description = "Valeur" + + name = fields.Char(strring="Name") diff --git a/custom_matrix_survey/models/survey.py b/custom_matrix_survey/models/survey_question.py similarity index 87% rename from custom_matrix_survey/models/survey.py rename to custom_matrix_survey/models/survey_question.py index eca2cdf..ce6cd31 100644 --- a/custom_matrix_survey/models/survey.py +++ b/custom_matrix_survey/models/survey_question.py @@ -1,8 +1,4 @@ -# -*- coding: utf-8 -*- - -from odoo import api, fields, models, _ -from odoo.exceptions import UserError, ValidationError - +from odoo import api, fields, models def dict_keys_startswith(dictionary, string): """Returns a dictionary containing the elements of whose keys start with . @@ -11,6 +7,7 @@ def dict_keys_startswith(dictionary, string): """ return {k: v for k, v in dictionary.items() if k.startswith(string)} + class SurveyQuestion(models.Model): _inherit = 'survey.question' @@ -39,23 +36,6 @@ class SurveyQuestion(models.Model): errors.update({answer_tag: self.constr_error_msg}) return errors -class SurveyLabel(models.Model): - _inherit = 'survey.label' - type = fields.Selection([ - ('free_text', 'Multiple Lines Text Box'), - ('textbox', 'Single Line Text Box'), - ('numerical_box', 'Numerical Value'), - ('dropdown', 'Dropdown'), - ('checkbox', 'Checkbox') - ], string='Type of Question', default="checkbox") - - dpvalues = fields.Many2many('dp.attributes.value', string="values") - -class SurveyLabelManyTags(models.Model): - _name = 'dp.attributes.value' - - name = fields.Char("Name") - class SurveyUserInputLine(models.Model): _inherit = 'survey.user_input_line' @@ -66,7 +46,7 @@ class SurveyUserInputLine(models.Model): ('free_text', 'Free Text'), ('suggestion', 'Suggestion'), ('dropdown', 'Dropdown')], string='Answer Type') - value_dropdown = fields.Many2one('dp.attributes.value', string="Value Dropdown") + 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 @@ -115,7 +95,7 @@ class SurveyUserInputLine(models.Model): 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): + if post.get(a_tag): sline = a_tag.split('_')[-1] label_obj = question.labels_ids.browse(int(sline)) if label_obj.type == 'textbox': @@ -135,4 +115,4 @@ class SurveyUserInputLine(models.Model): if no_answers: vals.update({'answer_type': None, 'skipped': True}) self.create(vals) - return True \ No newline at end of file + return True diff --git a/custom_matrix_survey/models/survey_user_input_line.py b/custom_matrix_survey/models/survey_user_input_line.py new file mode 100644 index 0000000..e0f2427 --- /dev/null +++ b/custom_matrix_survey/models/survey_user_input_line.py @@ -0,0 +1,91 @@ +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)} + + +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/custom_matrix_survey/reports/user_input.xml b/custom_matrix_survey/reports/user_input.xml new file mode 100644 index 0000000..fa21a3e --- /dev/null +++ b/custom_matrix_survey/reports/user_input.xml @@ -0,0 +1,88 @@ + + + + + + + + + + diff --git a/custom_matrix_survey/security/ir.model.access.csv b/custom_matrix_survey/security/ir.model.access.csv deleted file mode 100644 index 0550a48..0000000 --- a/custom_matrix_survey/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_dp_attributes_value,access_dp_attributes_value,model_dp_attributes_value,,1,1,1,1 diff --git a/custom_matrix_survey/security/ir_model_access.xml b/custom_matrix_survey/security/ir_model_access.xml new file mode 100644 index 0000000..a966fbe --- /dev/null +++ b/custom_matrix_survey/security/ir_model_access.xml @@ -0,0 +1,22 @@ + + + + survey.label.value All R + + 1 + 0 + 0 + 0 + + + + survey.label.value Survey Manager RWCU + + + 1 + 1 + 1 + 1 + + + diff --git a/custom_matrix_survey/static/src/js/custom.js b/custom_matrix_survey/static/src/js/custom.js deleted file mode 100644 index 4f58016..0000000 --- a/custom_matrix_survey/static/src/js/custom.js +++ /dev/null @@ -1,7 +0,0 @@ -odoo.define('custom_matrix_survey.custom', function(require) { -"use strict"; - // var ajax = require('web.ajax'); - $(document).ready(function() { - - }); -}); diff --git a/custom_matrix_survey/templates/matrix.xml b/custom_matrix_survey/templates/matrix.xml new file mode 100644 index 0000000..6ba5a61 --- /dev/null +++ b/custom_matrix_survey/templates/matrix.xml @@ -0,0 +1,53 @@ + + + + + + diff --git a/custom_matrix_survey/views/assets.xml b/custom_matrix_survey/views/assets.xml deleted file mode 100644 index 9c779e3..0000000 --- a/custom_matrix_survey/views/assets.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/custom_matrix_survey/views/custom_survey.xml b/custom_matrix_survey/views/custom_survey.xml deleted file mode 100644 index 933b778..0000000 --- a/custom_matrix_survey/views/custom_survey.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/custom_matrix_survey/views/survey_question.xml b/custom_matrix_survey/views/survey_question.xml new file mode 100644 index 0000000..13e8650 --- /dev/null +++ b/custom_matrix_survey/views/survey_question.xml @@ -0,0 +1,16 @@ + + + + + custom_matrix_survey survey.question form + survey.question + + + + + + + + + + diff --git a/custom_matrix_survey/views/survey_user_input.xml b/custom_matrix_survey/views/survey_user_input.xml new file mode 100644 index 0000000..ab00c66 --- /dev/null +++ b/custom_matrix_survey/views/survey_user_input.xml @@ -0,0 +1,15 @@ + + + + + custom_matrix_survey survey.user_input form + survey.user_input + + + +