Browse Source

[ADD] custom_matrix_survey module (by Kanak)

12.0
Rémi FRANÇOIS 5 years ago
parent
commit
0432228cf2
  1. 15
      custom_matrix_survey/COPYRIGHT
  2. 11
      custom_matrix_survey/LICENSE
  3. 3
      custom_matrix_survey/__init__.py
  4. 38
      custom_matrix_survey/__manifest__.py
  5. 3
      custom_matrix_survey/controllers/__init__.py
  6. 74
      custom_matrix_survey/controllers/main.py
  7. 1
      custom_matrix_survey/models/__init__.py
  8. 138
      custom_matrix_survey/models/survey.py
  9. 2
      custom_matrix_survey/security/ir.model.access.csv
  10. BIN
      custom_matrix_survey/static/description/banner.jpg
  11. BIN
      custom_matrix_survey/static/description/call-icon.png
  12. 2
      custom_matrix_survey/static/description/color code.txt
  13. BIN
      custom_matrix_survey/static/description/features-icon.png
  14. BIN
      custom_matrix_survey/static/description/icon-2.png
  15. BIN
      custom_matrix_survey/static/description/icon-3.png
  16. BIN
      custom_matrix_survey/static/description/icon-4.png
  17. BIN
      custom_matrix_survey/static/description/icon-5.png
  18. BIN
      custom_matrix_survey/static/description/icon-6.png
  19. BIN
      custom_matrix_survey/static/description/icon.png
  20. BIN
      custom_matrix_survey/static/description/icon1.png
  21. 248
      custom_matrix_survey/static/description/index.html
  22. BIN
      custom_matrix_survey/static/description/logo.png
  23. BIN
      custom_matrix_survey/static/description/main_image.jpg
  24. BIN
      custom_matrix_survey/static/description/support-icon.png
  25. BIN
      custom_matrix_survey/static/description/survey_1.png
  26. BIN
      custom_matrix_survey/static/description/survey_10.png
  27. BIN
      custom_matrix_survey/static/description/survey_11.png
  28. BIN
      custom_matrix_survey/static/description/survey_12.png
  29. BIN
      custom_matrix_survey/static/description/survey_13.png
  30. BIN
      custom_matrix_survey/static/description/survey_2.png
  31. BIN
      custom_matrix_survey/static/description/survey_3.png
  32. BIN
      custom_matrix_survey/static/description/survey_4.png
  33. BIN
      custom_matrix_survey/static/description/survey_5.png
  34. BIN
      custom_matrix_survey/static/description/survey_6.png
  35. BIN
      custom_matrix_survey/static/description/survey_8.png
  36. BIN
      custom_matrix_survey/static/description/survey_9.png
  37. 7
      custom_matrix_survey/static/src/js/custom.js
  38. 11
      custom_matrix_survey/views/assets.xml
  39. 127
      custom_matrix_survey/views/custom_survey.xml
  40. 49
      custom_matrix_survey/views/survey_views.xml

15
custom_matrix_survey/COPYRIGHT

@ -0,0 +1,15 @@
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.

11
custom_matrix_survey/LICENSE

@ -0,0 +1,11 @@
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.

3
custom_matrix_survey/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models
from . import controllers

38
custom_matrix_survey/__manifest__.py

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
#################################################################################
# Author : Kanak Infosystems LLP. (<http://kanakinfosystems.com/>)
# 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 <http://kanakinfosystems.com/license>
#################################################################################
{
'name': "Custom Matrix Survey",
'version': '1.0',
'summary': 'This app allows handling of complex survey forms with options like multiple choice questions, custom matrix etc.',
'description': """
Custom Matrix Survey.
================================
""",
'license': 'OPL-1',
'author': "Kanak Infosystems LLP.",
'website': "http://www.kanakinfosystems.com",
'images': ['static/description/banner.jpg'],
'category': 'Website',
'depends': ['survey_crm'],
'data': [
'security/ir.model.access.csv',
'views/survey_views.xml',
'views/custom_survey.xml',
],
'application': True,
'price': 49,
'currency': 'EUR',
}

3
custom_matrix_survey/controllers/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import main

74
custom_matrix_survey/controllers/main.py

@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
import json
from odoo import http
from odoo.http import request
import logging
from odoo.addons.survey.controllers.main import Survey
_logger = logging.getLogger(__name__)
class Survey(Survey):
@http.route(['/survey/prefill/<model("survey.survey"):survey>/<string:token>',
'/survey/prefill/<model("survey.survey"):survey>/<string:token>/<model("survey.page"):page>'],
type='http', auth='public', website=True)
def prefill(self, survey, token, page=None, **post):
UserInputLine = request.env['survey.user_input_line']
ret = {}
# Fetch previous answers
if page:
previous_answers = UserInputLine.sudo().search([('user_input_id.token', '=', token), ('page_id', '=', page.id)])
else:
previous_answers = UserInputLine.sudo().search([('user_input_id.token', '=', token)])
# Return non empty answers in a JSON compatible format
for answer in previous_answers:
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.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
elif answer.answer_type == 'text':
answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id)
answer_value = answer.value_text
elif answer.answer_type == 'number':
answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id)
answer_value = str(answer.value_number)
elif answer.answer_type == 'date':
answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id)
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
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
elif answer.answer_type == 'suggestion' and 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
if answer_value:
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)
else:
if answer.answer_type == 'free_text':
answer_value = answer.value_free_text
elif answer.answer_type == 'text' and answer.question_id.type == 'textbox':
answer_value = answer.value_text
elif answer.answer_type == 'text' and answer.question_id.type != 'textbox':
# here come comment answers for matrices, simple choice and multiple choice
answer_tag = "%s_%s" % (answer_tag, 'comment')
answer_value = answer.value_text
elif answer.answer_type == 'number':
answer_value = str(answer.value_number)
elif answer.answer_type == 'date':
answer_value = answer.value_date
elif answer.answer_type == 'suggestion' and not answer.value_suggested_row:
answer_value = answer.value_suggested.id
elif answer.answer_type == 'suggestion' and answer.value_suggested_row:
answer_tag = "%s_%s" % (answer_tag, answer.value_suggested_row.id)
answer_value = answer.value_suggested.id
if answer_value:
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)

1
custom_matrix_survey/models/__init__.py

@ -0,0 +1 @@
from . import survey

138
custom_matrix_survey/models/survey.py

@ -0,0 +1,138 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
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 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')
@api.multi
def validate_matrix(self, post, answer_tag):
self.ensure_one()
errors = {}
if self.constr_mandatory:
lines_number = len(self.labels_ids_2)
answer_candidates = dict_keys_startswith(post, answer_tag)
answer_candidates.pop(("%s_%s" % (answer_tag, 'comment')), '').strip()
# Number of lines that have been answered
if self.matrix_subtype == 'simple':
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':
answer_number = len({sk.rsplit('_', 1)[0] for sk in answer_candidates})
else:
raise RuntimeError("Invalid matrix subtype")
# Validate that each line has been answered
if answer_number != lines_number:
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'
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('dp.attributes.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

2
custom_matrix_survey/security/ir.model.access.csv

@ -0,0 +1,2 @@
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

BIN
custom_matrix_survey/static/description/banner.jpg

After

Width: 750  |  Height: 375  |  Size: 92 KiB

BIN
custom_matrix_survey/static/description/call-icon.png

After

Width: 29  |  Height: 28  |  Size: 771 B

2
custom_matrix_survey/static/description/color code.txt

@ -0,0 +1,2 @@
Blue color: 123246
Red Color: dc1d1d

BIN
custom_matrix_survey/static/description/features-icon.png

After

Width: 25  |  Height: 25  |  Size: 598 B

BIN
custom_matrix_survey/static/description/icon-2.png

After

Width: 97  |  Height: 96  |  Size: 3.7 KiB

BIN
custom_matrix_survey/static/description/icon-3.png

After

Width: 90  |  Height: 92  |  Size: 2.2 KiB

BIN
custom_matrix_survey/static/description/icon-4.png

After

Width: 90  |  Height: 92  |  Size: 2.7 KiB

BIN
custom_matrix_survey/static/description/icon-5.png

After

Width: 90  |  Height: 92  |  Size: 2.3 KiB

BIN
custom_matrix_survey/static/description/icon-6.png

After

Width: 90  |  Height: 92  |  Size: 2.1 KiB

BIN
custom_matrix_survey/static/description/icon.png

After

Width: 500  |  Height: 500  |  Size: 16 KiB

BIN
custom_matrix_survey/static/description/icon1.png

After

Width: 95  |  Height: 104  |  Size: 2.5 KiB

248
custom_matrix_survey/static/description/index.html

@ -0,0 +1,248 @@
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">
Matrix Survey
</h2>
</div>
</div>
</section>
<section class="oe_container" style="background-color: #eeeeee;">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Create Survey &amp; Add Survey pages</h2>
</div>
<div class="oe_span12">
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_1.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Add questions for survey page</h2>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_2.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="background-color: #eeeeee;">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Set question type as "matrix"</h2>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_3.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Set type of matrix</h2>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_4.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="background-color: #eeeeee;">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h3 class="oe_slogan">
Add answer's choices &amp; Set display type of questions <br/>
with different types of input methods
</h3>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_5.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Add multiple header rows</h2>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_6.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="background-color: #eeeeee;">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Fill survey</h2>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_8.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">View filled answers of survey</h2>
<div class="oe_row_img oe_centered">
<div class="">
<img src="survey_9.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="background-color: #eeeeee;">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Get print in .pdf</h2>
<div class="oe_row_img oe_centered">
<div class="oe_span6">
<img src="survey_10.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">PDF view</h2>
<div class="oe_row_img oe_centered">
<div class="oe_span6">
<img src="survey_11.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="background-color: #eeeeee;">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Print filled answers</h2>
<div class="oe_row_img oe_centered">
<div class="oe_span6">
<img src="survey_12.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Filled Answers</h2>
<div class="oe_row_img oe_centered">
<div class="oe_span6">
<img src="survey_13.png" class="oe_screenshot oe_centered" style="max-height: 400px;"/>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="row">
<div class="col-sm-12">
<div class="laptop-wrapper">
<iframe width="560" height="315" src="https://www.youtube.com/embed/F7u41nqf_iA" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
</div>
</section>
<section>
<div class="oe_row">
<div class="container-fluid">
<div class="oe_row">
<div class="col-md-12 col-xs-12 col-sm-12 mt32 mb32 text-center">
<img src="logo.png" style="height:100px;">
</div>
</div>
<div class="oe_row oe_screenshot" style="box-shadow: 3px 4px 25px 6px rgba(0, 0, 0, 0.2);;border-radius: 8px; background: #ECEDF0;">
<div class="col-sm-12">
<div class="text-center">
<a href="https://kanakinfosystems.com/kanak_aboutus"><h3 class="oe_slogan" style="border-bottom: 1px solid #123246; margin-top: 8px; font-size:33px; color:#123246; opacity:1; font-family:segoeuib">About kanak Infosystems</h3></a>
</div>
</div>
<div class="col-sm-12">
<h5 class="oe_slogan" style="margin-top: -9px; color:#123246;margin-bottom: 12px; opacity: 0.6; font-family:segoeuiz;"><i><b>"We are groupies wrapped in Creativity, Skills and Innovation"</b></i></h5>
<p style="font-family:segoeui">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.</p>
<p style="font-family:segoeui">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"!</p>
</div>
</div>
<div class="oe_row col-md-12 col-sm-12">
<div class="text-center">
<h2 style="color:#123246;font-family:segoeuib"> What We Do</h2>
</div>
</div>
<div class="row">
<div class="col-md-2 col-sm-2">
<img src="icon1.png">
<h6 style="margin-top: -10px;font-size: 9px;color:#123246;font-family:">Odoo Customization</h6>
</div>
<div class="col-md-2 col-sm-2">
<img src="icon-2.png">
<h6 style="margin-top: -1px;font-size: 9px;color:#123246;font-family:">Odoo Code Migration</h6>
</div>
<div class="col-md-2 col-sm-2">
<img src="icon-3.png">
<h6 style="margin-top: -1px;font-size: 9px;color:#123246;font-family:">Odoo Mobile App</h6>
</div>
<div class="col-md-2 col-sm-2">
<img src="icon-4.png">
<h6 style="margin-top: -1px;font-size: 9px;color:#123246;font-family:">Odoo DB Migration</h6>
</div>
<div class="col-md-2 col-sm-2">
<img src="icon-5.png">
<h6 style="margin-top: -1px;font-size: 9px;color:#123246;font-family:">Odoo Web Development</h6>
</div>
<div class="col-md-2 col-sm-2">
<img src="icon-6.png">
<h6 style="margin-top: -1px;font-size: 9px;color:#123246;font-family:">Odoo Themes</h6>
</div>
</div>
<div class="oe_row">
<div class="text-center" style="text-align: center;">
<a style="color:#dc1d1d; border:1px solid #dc1d1d; width:170px;" class="btn btn-lg" rel="nofollow" href="https://kanakinfosystems.com/contactus" target="_blank">
Contact Us
</a>
</div>
</div>
<div class="oe_row" style="box-shadow: 3px 5px 18px 6px rgba(0, 0, 0, 0.2);;border-radius: 8px; background: #ECEDF0; height:50px">
<div class="oe_row">
<div class="col-md-12 col-sm-12" style="padding-top: 10px;padding-left: 40px;">
<div class="col-md-4 col-sm-4" style="float: left; text-align: center;">
<span><img src="call-icon.png"/></span>
<span>Help</span>
</div>
<div class="col-md-4 col-sm-4" style="float: left; text-align: center;">
<span><img src="support-icon.png"/></span>
<span>Support</span>
</div>
<div class="col-md-4 col-sm-4" style="float: left; text-align: center;">
<span><img src="support-icon.png"/></span>
<span>Request New Features</span>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

BIN
custom_matrix_survey/static/description/logo.png

After

Width: 261  |  Height: 123  |  Size: 15 KiB

BIN
custom_matrix_survey/static/description/main_image.jpg

After

Width: 750  |  Height: 375  |  Size: 89 KiB

BIN
custom_matrix_survey/static/description/support-icon.png

After

Width: 28  |  Height: 28  |  Size: 846 B

BIN
custom_matrix_survey/static/description/survey_1.png

After

Width: 1351  |  Height: 608  |  Size: 108 KiB

BIN
custom_matrix_survey/static/description/survey_10.png

After

Width: 1351  |  Height: 608  |  Size: 134 KiB

BIN
custom_matrix_survey/static/description/survey_11.png

After

Width: 1351  |  Height: 608  |  Size: 78 KiB

BIN
custom_matrix_survey/static/description/survey_12.png

After

Width: 1351  |  Height: 608  |  Size: 133 KiB

BIN
custom_matrix_survey/static/description/survey_13.png

After

Width: 1351  |  Height: 608  |  Size: 79 KiB

BIN
custom_matrix_survey/static/description/survey_2.png

After

Width: 1351  |  Height: 608  |  Size: 88 KiB

BIN
custom_matrix_survey/static/description/survey_3.png

After

Width: 1351  |  Height: 608  |  Size: 109 KiB

BIN
custom_matrix_survey/static/description/survey_4.png

After

Width: 1351  |  Height: 608  |  Size: 99 KiB

BIN
custom_matrix_survey/static/description/survey_5.png

After

Width: 1351  |  Height: 608  |  Size: 106 KiB

BIN
custom_matrix_survey/static/description/survey_6.png

After

Width: 1351  |  Height: 608  |  Size: 77 KiB

BIN
custom_matrix_survey/static/description/survey_8.png

After

Width: 1351  |  Height: 608  |  Size: 76 KiB

BIN
custom_matrix_survey/static/description/survey_9.png

After

Width: 1351  |  Height: 608  |  Size: 65 KiB

7
custom_matrix_survey/static/src/js/custom.js

@ -0,0 +1,7 @@
odoo.define('custom_matrix_survey.custom', function(require) {
"use strict";
// var ajax = require('web.ajax');
$(document).ready(function() {
});
});

11
custom_matrix_survey/views/assets.xml

@ -0,0 +1,11 @@
<?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>

127
custom_matrix_survey/views/custom_survey.xml

@ -0,0 +1,127 @@
<?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>

49
custom_matrix_survey/views/survey_views.xml

@ -0,0 +1,49 @@
<?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>
Loading…
Cancel
Save