Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0] [MIG] survey_question_type_five_star: Migration to 15.0 #122

Draft
wants to merge 22 commits into
base: 15.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
89e931b
[10.0][ADD] - Survey five stars question type
sbejaoui Sep 27, 2018
89240de
[10.0][ADD] - Add survey_question_type_five_star setup
sbejaoui Sep 28, 2018
049160e
[10.0][IMP] - Handel five star question type for print and result survey
sbejaoui Oct 17, 2018
f11de0a
[FIX] - Fix Answer range for mandatory question
sbejaoui Nov 16, 2018
89a0ae8
[MIG] survey_question_type_five_star
olgamarcocb Sep 7, 2021
e24fa88
[IMP] survey_question_type_five_star: black, isort, prettier
olgamarcocb Sep 17, 2021
ac2ec75
[MIG] survey_question_type_five_star: Migration to 14.0
olgamarcocb Sep 17, 2021
94eb047
[ADD] compatible with conditional
olgamarcocb Sep 29, 2021
03fbd94
[UPD] Update survey_question_type_five_star.pot
oca-travis Jun 27, 2022
f0f2410
[UPD] README.rst
OCA-git-bot Jun 27, 2022
a915119
[FIX] survey_question_type_five_star: Fix readme
etobella Nov 4, 2022
02f7100
[UPD] README.rst
OCA-git-bot Nov 4, 2022
13d2fb1
survey_question_type_five_star 14.0.1.0.1
OCA-git-bot Nov 4, 2022
25eac27
Added translation using Weblate (Italian)
primes2h Nov 23, 2022
21af4d7
Translated using Weblate (Italian)
primes2h Nov 23, 2022
b1b484f
Translated using Weblate (Italian)
mymage May 29, 2023
7f668c5
[UPD] README.rst
OCA-git-bot Sep 3, 2023
bf4ef85
Translated using Weblate (Italian)
mymage Sep 25, 2023
93bd992
Update translation files
weblate Oct 10, 2023
0073fd5
Translated using Weblate (Italian)
mymage Oct 26, 2023
f681e0b
[IMP]survey_question_type_five_star: black, isort, prettier
bizzappdev May 7, 2024
a3af444
[MIG][15.0] survey_question_type_five_star:Migration to 15.0
bizzappdev May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/survey_question_type_five_star/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
77 changes: 77 additions & 0 deletions survey_question_type_five_star/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
===============================
Survey five stars question type
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:780d917b96e8866c744277042234b8beeb1bf6a333c931975c9daab19e80574b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsurvey-lightgray.png?logo=github
:target: https://github.com/OCA/survey/tree/15.0/survey_question_type_five_star
:alt: OCA/survey
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/survey-15-0/survey-15-0-survey_question_type_five_star
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/survey&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module add five stars rating question type for survey page

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/survey/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/survey/issues/new?body=module:%20survey_question_type_five_star%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
* Olga Marco <olga.marco@creublanca.es>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/survey <https://github.com/OCA/survey/tree/15.0/survey_question_type_five_star>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions survey_question_type_five_star/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions survey_question_type_five_star/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Survey five stars question type",
"summary": """
This module add five stars rating as question type for survey page""",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/survey",
"depends": ["survey"],
"data": ["views/survey_question.xml", "templates/survey_template.xml"],
"demo": [],
"assets": {
"survey.survey_assets": [
"survey_question_type_five_star/static/src/js/survey.js",
"survey_question_type_five_star/static/src/scss/parameters.scss",
"survey_question_type_five_star/static/src/scss/survey.scss",
],
},
}
91 changes: 91 additions & 0 deletions survey_question_type_five_star/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * survey_question_type_five_star
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-10-29 06:42+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: survey_question_type_five_star
#: model_terms:ir.ui.view,arch_db:survey_question_type_five_star.survey_question_form
msgid ""
"<i class=\"fa fa-star fa-2x\" title=\"star1\"/>\n"
" <i class=\"fa fa-star fa-2x\" title=\"star2\"/>\n"
" <i class=\"fa fa-star fa-2x\" title=\"star3\"/>\n"
" <i class=\"fa fa-star-o fa-2x\" title=\"star4\"/>\n"
" <i class=\"fa fa-star-o fa-2x\" title=\"star5\"/>"
msgstr ""
"<i class=\"fa fa-star fa-2x\" title=\"1 stella\"/>\n"
" <i class=\"fa fa-star fa-2x\" title=\"2 stelle\"/>\n"
" <i class=\"fa fa-star fa-2x\" title=\"3 stelle\"/>\n"
" <i class=\"fa fa-star-o fa-2x\" title=\"4 stelle\"/>\n"
" <i class=\"fa fa-star-o fa-2x\" title=\"5 stelle\"/>"

#. module: survey_question_type_five_star
#: code:addons/survey_question_type_five_star/models/survey_user_input_line.py:0
#, python-format
msgid "Answer is not in the right range"
msgstr "La risposta non è nell'intervallo corretto"

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question__display_name
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input__display_name
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input_line__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: survey_question_type_five_star
#: model:ir.model.fields.selection,name:survey_question_type_five_star.selection__survey_question__question_type__star_rate
msgid "Five Stars Rating"
msgstr "Valutazione cinque stelle"

#. module: survey_question_type_five_star
#: code:addons/survey_question_type_five_star/models/survey_user_input_line.py:0
#, python-format
msgid "Five stars rate question must have numeric answer"
msgstr ""
"La domanda di valutazione cinque stelle deve avere una risposta numerica"

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question__id
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input__id
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input_line__id
msgid "ID"
msgstr "ID"

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question____last_update
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input____last_update
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input_line____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question__question_type
msgid "Question Type"
msgstr "Tipo di domanda"

#. module: survey_question_type_five_star
#: model:ir.model,name:survey_question_type_five_star.model_survey_question
msgid "Survey Question"
msgstr "Domanda sondaggio"

#. module: survey_question_type_five_star
#: model:ir.model,name:survey_question_type_five_star.model_survey_user_input
msgid "Survey User Input"
msgstr "Risposta utente al sondaggio"

#. module: survey_question_type_five_star
#: model:ir.model,name:survey_question_type_five_star.model_survey_user_input_line
msgid "Survey User Input Line"
msgstr "Riga risposta utente al sondaggio"
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * survey_question_type_five_star
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: survey_question_type_five_star
#: model_terms:ir.ui.view,arch_db:survey_question_type_five_star.survey_question_form
msgid ""
"<i class=\"fa fa-star fa-2x\" title=\"star1\"/>\n"
" <i class=\"fa fa-star fa-2x\" title=\"star2\"/>\n"
" <i class=\"fa fa-star fa-2x\" title=\"star3\"/>\n"
" <i class=\"fa fa-star-o fa-2x\" title=\"star4\"/>\n"
" <i class=\"fa fa-star-o fa-2x\" title=\"star5\"/>"
msgstr ""

#. module: survey_question_type_five_star
#: code:addons/survey_question_type_five_star/models/survey_user_input_line.py:0
#: code:addons/survey_question_type_five_star/models/survey_user_input_line.py:0
#, python-format
msgid "Answer is not in the right range"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question__display_name
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input__display_name
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input_line__display_name
msgid "Display Name"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model.fields.selection,name:survey_question_type_five_star.selection__survey_question__question_type__star_rate
msgid "Five Stars Rating"
msgstr ""

#. module: survey_question_type_five_star
#: code:addons/survey_question_type_five_star/models/survey_user_input_line.py:0
#, python-format
msgid "Five stars rate question must have numeric answer"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question__id
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input__id
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input_line__id
msgid "ID"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question____last_update
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input____last_update
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_user_input_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model.fields,field_description:survey_question_type_five_star.field_survey_question__question_type
msgid "Question Type"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model,name:survey_question_type_five_star.model_survey_question
msgid "Survey Question"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model,name:survey_question_type_five_star.model_survey_user_input
msgid "Survey User Input"
msgstr ""

#. module: survey_question_type_five_star
#: model:ir.model,name:survey_question_type_five_star.model_survey_user_input_line
msgid "Survey User Input Line"
msgstr ""
2 changes: 2 additions & 0 deletions survey_question_type_five_star/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import survey_question
from . import survey_user_input_line
58 changes: 58 additions & 0 deletions survey_question_type_five_star/models/survey_question.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import collections

from odoo import fields, models, tools


class SurveyQuestion(models.Model):

_inherit = "survey.question"

question_type = fields.Selection(
selection_add=[("star_rate", "Five Stars Rating")], ondelete={"foo": "set null"}
)

def _get_stats_summary_data(self, user_input_lines):
stats = super()._get_stats_summary_data(user_input_lines)
if self.question_type in ["star_rate"]:
stats.update(self._get_stats_summary_data_numerical(user_input_lines))
stats.update(
{
"common_lines": collections.Counter(
user_input_lines.filtered(lambda line: not line.skipped).mapped(
"value_numerical_box"
)
).most_common(5),
"right_inputs_count": len(
user_input_lines.filtered(
lambda line: line.answer_is_correct
).mapped("user_input_id")
),
}
)
return stats

def validate_star_rate(self, post, answer_tag):
self.ensure_one()
errors = {}
answer = post[answer_tag].strip()
# Empty answer to mandatory question
if self.constr_mandatory and not answer:
errors.update({answer_tag: self.constr_error_msg})
# Checks if user input is a number
if answer:
try:
floatanswer = float(answer)
except ValueError:
errors.update({answer_tag: "This is not a number"})
return errors
# Answer is not in the right range
with tools.ignore(Exception):
# 0 answer to mandatory question
if self.constr_mandatory:
if floatanswer == 0:
errors.update({answer_tag: self.constr_error_msg})
if not (0 <= floatanswer <= 5):
errors.update({answer_tag: "Answer is not in the right range"})
return errors
Loading
Loading