Rémi FRANÇOIS
5 years ago
22 changed files with 720 additions and 231 deletions
-
2custom_matrix_survey/__init__.py
-
11custom_matrix_survey/__manifest__.py
-
2custom_matrix_survey/controllers/__init__.py
-
2custom_matrix_survey/controllers/main.py
-
187custom_matrix_survey/i18n/custom_matrix_survey.pot
-
186custom_matrix_survey/i18n/fr.po
-
5custom_matrix_survey/models/__init__.py
-
16custom_matrix_survey/models/survey_label.py
-
8custom_matrix_survey/models/survey_label_value.py
-
26custom_matrix_survey/models/survey_question.py
-
91custom_matrix_survey/models/survey_user_input_line.py
-
88custom_matrix_survey/reports/user_input.xml
-
2custom_matrix_survey/security/ir.model.access.csv
-
22custom_matrix_survey/security/ir_model_access.xml
-
7custom_matrix_survey/static/src/js/custom.js
-
53custom_matrix_survey/templates/matrix.xml
-
11custom_matrix_survey/views/assets.xml
-
127custom_matrix_survey/views/custom_survey.xml
-
16custom_matrix_survey/views/survey_question.xml
-
15custom_matrix_survey/views/survey_user_input.xml
-
19custom_matrix_survey/views/survey_user_input_line.xml
-
49custom_matrix_survey/views/survey_views.xml
@ -1,3 +1,3 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
from . import models |
from . import models |
||||
from . import controllers |
from . import controllers |
@ -1,3 +1 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
from . import main |
from . import main |
@ -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 "" |
||||
|
|
@ -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" |
@ -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 |
@ -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") |
@ -0,0 +1,8 @@ |
|||||
|
from odoo import models, fields |
||||
|
|
||||
|
|
||||
|
class SurveyLabelValue(models.Model): |
||||
|
_name = 'survey.label.value' |
||||
|
_description = "Valeur" |
||||
|
|
||||
|
name = fields.Char(strring="Name") |
@ -0,0 +1,91 @@ |
|||||
|
from odoo import models, fields, api |
||||
|
|
||||
|
def dict_keys_startswith(dictionary, string): |
||||
|
"""Returns a dictionary containing the elements of <dict> whose keys start with <string>. |
||||
|
.. 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 |
@ -0,0 +1,88 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<template id="report_survey_answers_document"> |
||||
|
<t t-call="web.internal_layout"> |
||||
|
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})"/> |
||||
|
<div class="page"> |
||||
|
<div class="oe_structure"/> |
||||
|
<div class="row mt32 mb32" style="display: inherit;"> |
||||
|
<h3 class="text-center"><t t-esc="doc.survey_id.title"/></h3> |
||||
|
<t t-set="questions" t-value="doc.user_input_line_ids.mapped('question_id')"/> |
||||
|
<!-- <h3 class="text-center"><t t-esc="doc."/></h3> --> |
||||
|
<t t-foreach="questions" t-as="qs"> |
||||
|
<t t-if="qs.matrix_subtype == 'custom_row'"> |
||||
|
<h4 class="text-center mt16 mb16" t-field="qs.question"/> |
||||
|
<table class="table" style="width:100%;"> |
||||
|
<thead> |
||||
|
<tr style="width:100%;text-align: center"> |
||||
|
<th style="text-align: center">#</th> |
||||
|
<t t-foreach="qs.labels_ids" t-as="lb"> |
||||
|
<th style="text-align: center"> <span t-field="lb.value"/></th> |
||||
|
</t> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<t t-foreach="qs.labels_ids_2" t-as="lb2"> |
||||
|
<tr style="text-align: center"> |
||||
|
<td style="text-align: center"><strong t-field="lb2.value"></strong></td> |
||||
|
<t t-foreach="qs.labels_ids" t-as="lb"> |
||||
|
<t t-set="flag" t-value="false"/> |
||||
|
<t t-foreach="doc.user_input_line_ids" t-as="ans"> |
||||
|
<t t-if="ans.value_suggested_row.id == lb2.id"> |
||||
|
<t t-if="ans.value_suggested.id == lb.id"> |
||||
|
<td class="text-center"> |
||||
|
<t t-if="ans.answer_type == 'text'"> |
||||
|
<span t-field="ans.value_text"/> |
||||
|
</t> |
||||
|
<t t-if="ans.answer_type == 'number'"> |
||||
|
<span t-field="ans.value_number"/> |
||||
|
</t> |
||||
|
<t t-if="ans.answer_type == 'free_text'"> |
||||
|
<span t-field="ans.value_free_text"/> |
||||
|
</t> |
||||
|
<t t-if="ans.answer_type == 'suggestion'"> |
||||
|
<span class="fa fa-check"/> |
||||
|
</t> |
||||
|
<t t-if="ans.answer_type == 'dropdown'"> |
||||
|
<span t-field="ans.value_dropdown"/> |
||||
|
</t> |
||||
|
</td> |
||||
|
<t t-set="flag" t-value="true"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
</t> |
||||
|
<t t-if="not flag"> |
||||
|
<td style="text-align: center"> |
||||
|
</td> |
||||
|
</t> |
||||
|
</t> |
||||
|
</tr> |
||||
|
</t> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</t> |
||||
|
</t> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</template> |
||||
|
|
||||
|
<template id="report_survey_answers"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-foreach="docs" t-as="doc"> |
||||
|
<t t-call="custom_matrix_survey.report_survey_answers_document"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
|
||||
|
<report |
||||
|
id="action_view_pdf_answers" |
||||
|
string="Answers" |
||||
|
model="survey.user_input" |
||||
|
report_type="qweb-pdf" |
||||
|
file="custom_matrix_survey.report_survey_answers" |
||||
|
name="custom_matrix_survey.report_survey_answers" |
||||
|
print_report_name="'answer - %s' % (object.survey_id.title)"/> |
||||
|
|
||||
|
</odoo> |
@ -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 |
|
@ -0,0 +1,22 @@ |
|||||
|
<odoo> |
||||
|
|
||||
|
<record id="survey_label_value_all_r" model="ir.model.access"> |
||||
|
<field name="name">survey.label.value All R</field> |
||||
|
<field name="model_id" ref="custom_matrix_survey.model_survey_label_value"/> |
||||
|
<field name="perm_read">1</field> |
||||
|
<field name="perm_write">0</field> |
||||
|
<field name="perm_create">0</field> |
||||
|
<field name="perm_unlink">0</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="survey_label_value_manager_rwcu" model="ir.model.access"> |
||||
|
<field name="name">survey.label.value Survey Manager RWCU</field> |
||||
|
<field name="model_id" ref="custom_matrix_survey.model_survey_label_value"/> |
||||
|
<field name="group_id" ref="survey.group_survey_manager"/> |
||||
|
<field name="perm_read">1</field> |
||||
|
<field name="perm_write">1</field> |
||||
|
<field name="perm_create">1</field> |
||||
|
<field name="perm_unlink">1</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -1,7 +0,0 @@ |
|||||
odoo.define('custom_matrix_survey.custom', function(require) { |
|
||||
"use strict"; |
|
||||
// var ajax = require('web.ajax');
|
|
||||
$(document).ready(function() { |
|
||||
|
|
||||
}); |
|
||||
}); |
|
@ -0,0 +1,53 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<template id="matrix" inherit_id="survey.matrix"> |
||||
|
<xpath expr="//table" position="replace"> |
||||
|
<table class="table table-hover"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th></th> |
||||
|
<th t-foreach="question.labels_ids" t-as="col_label"><span t-field="col_label.value"/></th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr t-foreach="question.labels_ids_2" t-as="row_label"> |
||||
|
<th><span t-field="row_label.value"/></th> |
||||
|
<td t-foreach="question.labels_ids" t-as="col_label"> |
||||
|
<input t-if="question.matrix_subtype == 'simple'" type="radio" t-att-name="'%s_%s' % (prefix, row_label.id)" t-att-value='col_label.id'/> |
||||
|
<t t-if="question.matrix_subtype == 'custom_row'"> |
||||
|
<t t-if="col_label.type == 'textbox'"> |
||||
|
<input type="text" class="form-control" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"/> |
||||
|
</t> |
||||
|
<t t-if="col_label.type == 'free_text'"> |
||||
|
<textarea class="form-control" rows="3" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"></textarea> |
||||
|
</t> |
||||
|
<t t-if="col_label.type == 'numerical_box'"> |
||||
|
<input type="number" step="any" class="form-control" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"/> |
||||
|
</t> |
||||
|
<t t-if="col_label.type == 'date'"> |
||||
|
<div class='input-group date'> |
||||
|
<input type="text" date="true" class="form-control date" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
<t t-if="col_label.type == 'dropdown'"> |
||||
|
<select t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" class="form-control" id="seldpbox1"> |
||||
|
<option></option> |
||||
|
<t t-foreach="col_label.dpvalues" t-as="dpv"> |
||||
|
<option t-att-value="dpv.id"><t t-esc="dpv.name"/></option> |
||||
|
</t> |
||||
|
</select> |
||||
|
</t> |
||||
|
<t t-if="col_label.type == 'checkbox'"> |
||||
|
<input type="checkbox" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" t-att-value='col_label.id'/> |
||||
|
</t> |
||||
|
</t> |
||||
|
<input t-if="question.matrix_subtype == 'multiple'" type="checkbox" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" t-att-value='col_label.id'/> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
|
||||
|
</odoo> |
@ -1,11 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<odoo> |
|
||||
<template id="assets_frontend" inherit_id="website.assets_frontend" name="Website Custom Survey Assest"> |
|
||||
<xpath expr="//link[last()]" position="after"> |
|
||||
<link href="/custom_matrix_survey/static/src/css/custom.css" rel="stylesheet" type="text/css" /> |
|
||||
</xpath> |
|
||||
<xpath expr="//script[last()]" position="after"> |
|
||||
<script src="/custom_matrix_survey/static/src/js/custom.js"></script> |
|
||||
</xpath> |
|
||||
</template> |
|
||||
</odoo> |
|
@ -1,127 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<odoo> |
|
||||
<data> |
|
||||
<template id="matrix_custom" inherit_id="survey.matrix"> |
|
||||
<xpath expr="//table" position="replace"> |
|
||||
<table class="table table-hover"> |
|
||||
<thead> |
|
||||
<tr> |
|
||||
<th> </th> |
|
||||
<th t-foreach="question.labels_ids" t-as="col_label"><span t-field="col_label.value" /></th> |
|
||||
</tr> |
|
||||
</thead> |
|
||||
<tbody> |
|
||||
<tr t-foreach="question.labels_ids_2" t-as="row_label"> |
|
||||
<th><span t-field="row_label.value" /></th> |
|
||||
<td t-foreach="question.labels_ids" t-as="col_label"> |
|
||||
<input t-if="question.matrix_subtype == 'simple'" type="radio" t-att-name="'%s_%s' % (prefix, row_label.id)" t-att-value='col_label.id' /> |
|
||||
<t t-if="question.matrix_subtype == 'custom_row'"> |
|
||||
<t t-if="col_label.type == 'textbox'"> |
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"/> |
|
||||
</t> |
|
||||
<t t-if="col_label.type == 'free_text'"> |
|
||||
<textarea class="form-control" rows="3" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"></textarea> |
|
||||
</t> |
|
||||
<t t-if="col_label.type == 'numerical_box'"> |
|
||||
<input type="number" step="any" class="form-control" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"/> |
|
||||
</t> |
|
||||
<t t-if="col_label.type == 'date'"> |
|
||||
<div class='input-group date'> |
|
||||
<input type="text" date="true" class="form-control date" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)"/> |
|
||||
</div> |
|
||||
</t> |
|
||||
<t t-if="col_label.type == 'dropdown'"> |
|
||||
<select t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" class="form-control" id="seldpbox1"> |
|
||||
<option></option> |
|
||||
<t t-foreach="col_label.dpvalues" t-as="dpv"> |
|
||||
<option t-att-value="dpv.id"><t t-esc="dpv.name"/></option> |
|
||||
</t> |
|
||||
</select> |
|
||||
</t> |
|
||||
<t t-if="col_label.type == 'checkbox'"> |
|
||||
<input type="checkbox" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" t-att-value='col_label.id' /> |
|
||||
</t> |
|
||||
</t> |
|
||||
<input t-if="question.matrix_subtype == 'multiple'" type="checkbox" t-att-name="'%s_%s_%s' % (prefix, row_label.id, col_label.id)" t-att-value='col_label.id' /> |
|
||||
</td> |
|
||||
</tr> |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</xpath> |
|
||||
</template> |
|
||||
|
|
||||
<template id="report_survey_answers_document"> |
|
||||
<t t-call="web.internal_layout"> |
|
||||
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" /> |
|
||||
<div class="page"> |
|
||||
<div class="oe_structure"/> |
|
||||
<div class="row mt32 mb32" style="display: inherit;"> |
|
||||
<h3 class="text-center"><t t-esc="doc.survey_id.title"/></h3> |
|
||||
<t t-set="questions" t-value="doc.user_input_line_ids.mapped('question_id')"/> |
|
||||
<!-- <h3 class="text-center"><t t-esc="doc."/></h3> --> |
|
||||
<t t-foreach="questions" t-as="qs"> |
|
||||
<t t-if="qs.matrix_subtype == 'custom_row'"> |
|
||||
<h4 class="text-center mt16 mb16" t-field="qs.question"/> |
|
||||
<table class="table" style="width:100%;"> |
|
||||
<thead> |
|
||||
<tr style="width:100%;text-align: center"> |
|
||||
<th style="text-align: center">#</th> |
|
||||
<t t-foreach="qs.labels_ids" t-as="lb"> |
|
||||
<th style="text-align: center"> <span t-field="lb.value"/></th> |
|
||||
</t> |
|
||||
</tr> |
|
||||
</thead> |
|
||||
<tbody> |
|
||||
<t t-foreach="qs.labels_ids_2" t-as="lb2"> |
|
||||
<tr style="text-align: center"> |
|
||||
<td style="text-align: center"><strong t-field="lb2.value"></strong></td> |
|
||||
<t t-foreach="qs.labels_ids" t-as="lb"> |
|
||||
<t t-set="flag" t-value="false"/> |
|
||||
<t t-foreach="doc.user_input_line_ids" t-as="ans"> |
|
||||
<t t-if="ans.value_suggested_row.id == lb2.id"> |
|
||||
<t t-if="ans.value_suggested.id == lb.id"> |
|
||||
<td class="text-center"> |
|
||||
<t t-if="ans.answer_type == 'text'"> |
|
||||
<span t-field="ans.value_text"/> |
|
||||
</t> |
|
||||
<t t-if="ans.answer_type == 'number'"> |
|
||||
<span t-field="ans.value_number"/> |
|
||||
</t> |
|
||||
<t t-if="ans.answer_type == 'free_text'"> |
|
||||
<span t-field="ans.value_free_text"/> |
|
||||
</t> |
|
||||
<t t-if="ans.answer_type == 'suggestion'"> |
|
||||
<span class="fa fa-check"/> |
|
||||
</t> |
|
||||
<t t-if="ans.answer_type == 'dropdown'"> |
|
||||
<span t-field="ans.value_dropdown"/> |
|
||||
</t> |
|
||||
</td> |
|
||||
<t t-set="flag" t-value="true"/> |
|
||||
</t> |
|
||||
</t> |
|
||||
</t> |
|
||||
<t t-if="not flag"> |
|
||||
<td style="text-align: center"> |
|
||||
</td> |
|
||||
</t> |
|
||||
</t> |
|
||||
</tr> |
|
||||
</t> |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</t> |
|
||||
</t> |
|
||||
</div> |
|
||||
</div> |
|
||||
</t> |
|
||||
</template> |
|
||||
<template id="report_survey_answers"> |
|
||||
<t t-call="web.html_container"> |
|
||||
<t t-foreach="docs" t-as="doc"> |
|
||||
<t t-call="custom_matrix_survey.report_survey_answers_document"/> |
|
||||
</t> |
|
||||
</t> |
|
||||
</template> |
|
||||
</data> |
|
||||
</odoo> |
|
@ -0,0 +1,16 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<record id="survey_question_form" model="ir.ui.view"> |
||||
|
<field name="name">custom_matrix_survey survey.question form</field> |
||||
|
<field name="model">survey.question</field> |
||||
|
<field name="inherit_id" ref="survey.survey_question_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//notebook//page//field[@name='labels_ids']//tree" position="inside"> |
||||
|
<field name="type"/> |
||||
|
<field name="dpvalues" widget="many2many_tags" attrs="{'invisible': [('type', '!=', 'dropdown')]}"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<record id="survey_user_input_form" model="ir.ui.view"> |
||||
|
<field name="name">custom_matrix_survey survey.user_input form</field> |
||||
|
<field name="model">survey.user_input</field> |
||||
|
<field name="inherit_id" ref="survey.survey_user_input_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//form//header//button[@name='action_view_answers']" position="after"> |
||||
|
<button name="%(action_view_pdf_answers)d" states="done" string="Print PDF Answers" type="action" class="oe_highlight"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,19 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<record id="survey_user_input_line_form" model="ir.ui.view"> |
||||
|
<field name="name">custom_matrix_survey survey.user_input_line form</field> |
||||
|
<field name="model">survey.user_input_line</field> |
||||
|
<field name="inherit_id" ref="survey.survey_user_input_line_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<field name="value_text" position="after"> |
||||
|
<field name="value_dropdown" attrs="{'invisible': [('answer_type','!=','dropdown')]}"/> |
||||
|
<field name="matrix_subtype_id"/> |
||||
|
</field> |
||||
|
<field name="value_suggested" position="replace"> |
||||
|
<field name="value_suggested" colspan='2' attrs="{'invisible': [ ('answer_type','!=','suggestion'), ('matrix_subtype_id', '!=', 'custom_row')]}"/> |
||||
|
</field> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -1,49 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<odoo> |
|
||||
<record model="ir.ui.view" id="survey_question_custom_form"> |
|
||||
<field name="name">Form view for survey custom question</field> |
|
||||
<field name="model">survey.question</field> |
|
||||
<field name="inherit_id" ref="survey.survey_question_form"/> |
|
||||
<field name="arch" type="xml"> |
|
||||
<xpath expr="//notebook//page//field[@name='labels_ids']//tree" position="inside"> |
|
||||
<field name="type"/> |
|
||||
<field name="dpvalues" widget="many2many_tags" attrs="{'invisible': [('type', '!=', 'dropdown')]}"/> |
|
||||
</xpath> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
<record model="ir.ui.view" id="survey_user_input_line_custom_form"> |
|
||||
<field name="name">survey_user_input_line_custom_form</field> |
|
||||
<field name="model">survey.user_input_line</field> |
|
||||
<field name="inherit_id" ref="survey.survey_user_input_line_form"/> |
|
||||
<field name="arch" type="xml"> |
|
||||
<field name="value_text" position="after"> |
|
||||
<field name="value_dropdown" attrs="{'invisible': [('answer_type','!=','dropdown')]}"/> |
|
||||
<field name="matrix_subtype_id"/> |
|
||||
</field> |
|
||||
<field name="value_suggested" position="replace"> |
|
||||
<field name="value_suggested" colspan='2' attrs="{'invisible': [ ('answer_type','!=','suggestion'), ('matrix_subtype_id', '!=', 'custom_row')]}"/> |
|
||||
</field> |
|
||||
</field> |
|
||||
</record> |
|
||||
<report |
|
||||
id="action_view_pdf_answers" |
|
||||
string="Answers" |
|
||||
model="survey.user_input" |
|
||||
report_type="qweb-pdf" |
|
||||
file="custom_matrix_survey.report_survey_answers" |
|
||||
name="custom_matrix_survey.report_survey_answers" |
|
||||
print_report_name="'answer - %s' % (object.survey_id.title)" |
|
||||
/> |
|
||||
|
|
||||
<record model="ir.ui.view" id="survey_user_input_custom_form"> |
|
||||
<field name="name">survey_user_input_custom_form</field> |
|
||||
<field name="model">survey.user_input</field> |
|
||||
<field name="inherit_id" ref="survey.survey_user_input_form"/> |
|
||||
<field name="arch" type="xml"> |
|
||||
<xpath expr="//form//header//button[@name='action_view_answers']" position="after"> |
|
||||
<button name="%(action_view_pdf_answers)d" states="done" string="Print PDF Answers" type="action" class="oe_highlight" /> |
|
||||
</xpath> |
|
||||
</field> |
|
||||
</record> |
|
||||
</odoo> |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue