-
-
Notifications
You must be signed in to change notification settings - Fork 128
[18.0][MIG] survey_xlsx: Migration to 18.0 #176
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
Open
ByteMeAsap
wants to merge
14
commits into
OCA:18.0
Choose a base branch
from
ByteMeAsap:18.0-mig-survey_xlsx
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1f95b6e
[ADD] survey_xlsx
olgamarcocb 84c1456
[UPD] Update survey_xlsx.pot
12e01a0
[UPD] README.rst
OCA-git-bot ee3d7a0
[ADD] icon.png
OCA-git-bot d8f76a4
Added translation using Weblate (Italian)
primes2h a080e4a
Translated using Weblate (Italian)
primes2h 24b8d7a
Translated using Weblate (Italian)
mymage c862714
[UPD] README.rst
OCA-git-bot a457d4a
Translated using Weblate (Italian)
mymage 6a3e38c
[16.0][MIG] survey_xlsx: Migration to 16.0
Abranes 51c1535
[UPD] Update survey_xlsx.pot
1da58cb
Update translation files
weblate 37ce7b9
[IMP] survey_xlsx: pre-commit auto fixes
ByteMeAsap 07d26e7
[MIG] : Migration to 18.0
ByteMeAsap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| =========== | ||
| Survey XLSX | ||
| =========== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:0647ba4a4a0c3a3dc8f4e7b281d9bc6482d39efc59b2da832241080c29d611ad | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |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/18.0/survey_xlsx | ||
| :alt: OCA/survey | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/survey-18-0/survey-18-0-survey_xlsx | ||
| :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=18.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module allows to print a XLSX report with the survey results. | ||
|
|
||
| **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_xlsx%0Aversion:%2018.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 | ||
| ------- | ||
|
|
||
| * Creu Blanca | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - 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/18.0/survey_xlsx>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import report | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Copyright 2022 CreuBlanca | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
|
||
| { | ||
| "name": "Survey XLSX", | ||
| "summary": """ | ||
| XLSX Report to show the survey results""", | ||
| "version": "18.0.1.0.0", | ||
| "license": "AGPL-3", | ||
| "installable": True, | ||
| "application": False, | ||
| "author": "Creu Blanca, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/survey", | ||
| "depends": ["survey", "report_xlsx"], | ||
| "data": ["report/report_survey_xlsx.xml"], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * survey_xlsx | ||
| # | ||
| 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_xlsx | ||
| #. odoo-python | ||
| #: code:addons/survey_xlsx/report/report_survey_xlsx.py:0 | ||
| #, python-format | ||
| msgid "Created on" | ||
| msgstr "Creato il" | ||
|
|
||
| #. module: survey_xlsx | ||
| #. odoo-python | ||
| #: code:addons/survey_xlsx/report/report_survey_xlsx.py:0 | ||
| #, python-format | ||
| msgid "Partner" | ||
| msgstr "Partner" | ||
|
|
||
| #. module: survey_xlsx | ||
| #: model:ir.model,name:survey_xlsx.model_survey_user_input_line | ||
| msgid "Survey User Input Line" | ||
| msgstr "Riga risposta utente al sondaggio" | ||
|
|
||
| #. module: survey_xlsx | ||
| #: model:ir.actions.report,name:survey_xlsx.report_survey_xlsx | ||
| msgid "XLSX Report Survey" | ||
| msgstr "Resoconto sondaggio XLSX" | ||
|
|
||
| #. module: survey_xlsx | ||
| #: model:ir.model,name:survey_xlsx.model_report_survey_xlsx | ||
| msgid "XLSX Report to show all the results for the survey" | ||
| msgstr "Resoconto XLSX per visualizzare tutti i risultati del sondaggio" | ||
|
|
||
| #~ msgid "Display Name" | ||
| #~ msgstr "Nome visualizzato" | ||
|
|
||
| #~ msgid "ID" | ||
| #~ msgstr "ID" | ||
|
|
||
| #~ msgid "Last Modified on" | ||
| #~ msgstr "Ultima modifica il" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * survey_xlsx | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 16.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_xlsx | ||
| #. odoo-python | ||
| #: code:addons/survey_xlsx/report/report_survey_xlsx.py:0 | ||
| #, python-format | ||
| msgid "Created on" | ||
| msgstr "" | ||
|
|
||
| #. module: survey_xlsx | ||
| #. odoo-python | ||
| #: code:addons/survey_xlsx/report/report_survey_xlsx.py:0 | ||
| #, python-format | ||
| msgid "Partner" | ||
| msgstr "" | ||
|
|
||
| #. module: survey_xlsx | ||
| #: model:ir.model,name:survey_xlsx.model_survey_user_input_line | ||
| msgid "Survey User Input Line" | ||
| msgstr "" | ||
|
|
||
| #. module: survey_xlsx | ||
| #: model:ir.actions.report,name:survey_xlsx.report_survey_xlsx | ||
| msgid "XLSX Report Survey" | ||
| msgstr "" | ||
|
|
||
| #. module: survey_xlsx | ||
| #: model:ir.model,name:survey_xlsx.model_report_survey_xlsx | ||
| msgid "XLSX Report to show all the results for the survey" | ||
| msgstr "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import survey_user_input_line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright 2022 CreuBlanca | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
| from odoo import models | ||
|
|
||
|
|
||
| class SurveyUserInputLine(models.Model): | ||
| _inherit = "survey.user_input.line" | ||
|
|
||
| def _get_xlsx_value(self): | ||
| if self.answer_type == "suggestion": | ||
| return self.suggested_answer_id.value | ||
| if self.answer_type == "date": | ||
| return self.value_date.isoformat() | ||
| return self[f"value_{self.answer_type}"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Olga Marco \<<olga.marco@creublanca.es>\> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| This module allows to print a XLSX report with the survey results. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import report_survey_xlsx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Copyright 2022 CreuBlanca | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
| import datetime | ||
| from collections import defaultdict | ||
|
|
||
| from odoo import models | ||
|
|
||
|
|
||
| class Iterator: | ||
| def __init__(self, value=0): | ||
| self.value = value | ||
|
|
||
| def next(self): | ||
| self.value += 1 | ||
| return self.value | ||
|
|
||
|
|
||
| class ReportSurveyXlsx(models.AbstractModel): | ||
| _name = "report.survey.xlsx" | ||
| _inherit = "report.report_xlsx.abstract" | ||
| _description = "XLSX Report to show all the results for the survey" | ||
|
|
||
| def _pre_generate_xlsx_report_header(self, sheet, results, cols, bold): | ||
| # Hook for adding some extra headers at the beginning | ||
| sheet.write(0, cols["partner_id"], self.env._("Partner"), bold) | ||
| sheet.write(0, cols["create_date"], self.env._("Created on"), bold) | ||
|
|
||
| def _post_generate_xlsx_report_header(self, sheet, results, cols, bold): | ||
| # Hook for adding some extra headers at the end | ||
| pass | ||
|
|
||
| def _add_extra_data(self, user_input_data, user_input, cols): | ||
| # Hook for adding extra data if needed | ||
| for fieldname, col in cols.items(): | ||
| if fieldname in user_input._fields: | ||
| if not isinstance(user_input[fieldname], models.Model): | ||
| user_input_data[col] = [user_input[fieldname]] | ||
| elif user_input[fieldname]: | ||
| user_input_data[col] = [user_input[fieldname].display_name] | ||
|
|
||
| def generate_xlsx_report(self, workbook, data, results): | ||
| n_cols = Iterator(-1) | ||
| sheet = workbook.add_worksheet("Survey Results") | ||
| bold = workbook.add_format({"bold": True}) | ||
| no_bold = workbook.add_format({"bold": False}) | ||
| cols = defaultdict(n_cols.next) | ||
| data = defaultdict(lambda: defaultdict(list)) | ||
| self._pre_generate_xlsx_report_header(sheet, results, cols, bold) | ||
| # One column by question | ||
| for question in results.question_ids: | ||
| sheet.write(0, cols[f"question_{question.id}"], question.title, bold) | ||
| self._post_generate_xlsx_report_header(sheet, results, n_cols, bold) | ||
| user_inputs = self.env["survey.user_input"].search( | ||
| self._get_input_domain(results) | ||
| ) | ||
| for user_input in user_inputs: | ||
| self._add_extra_data(data[user_input.id], user_input, cols) | ||
| for user_answer in user_input.user_input_line_ids: | ||
| question_id = f"question_{user_answer.question_id.id}" | ||
| if question_id not in cols or user_answer.skipped: | ||
| # We should ignore old removed questions | ||
| continue | ||
| data[user_input.id][cols[question_id]].append( | ||
| user_answer._get_xlsx_value() | ||
| ) | ||
| row = 0 | ||
| for answer_data in data.values(): | ||
| row += 1 | ||
| for col_id, answer_vals in answer_data.items(): | ||
ByteMeAsap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if isinstance(answer_vals[0], datetime.datetime): | ||
| date = answer_vals[0].date() | ||
| answer_vals[0] = date.isoformat() | ||
| result = ( | ||
| answer_vals[0] if len(answer_vals) == 1 else ", ".join(answer_vals) | ||
| ) | ||
| sheet.write( | ||
| row, | ||
| col_id, | ||
| result, | ||
| no_bold, | ||
| ) | ||
|
|
||
| def _get_input_domain(self, results): | ||
| return [ | ||
| ("survey_id", "=", results.id), | ||
| ("test_entry", "=", False), | ||
| ("state", "=", "done"), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <odoo> | ||
| <record id="report_survey_xlsx" model="ir.actions.report"> | ||
| <field name="name">XLSX Report Survey</field> | ||
| <field name="model">survey.survey</field> | ||
| <field name="type">ir.actions.report</field> | ||
| <field name="report_type">xlsx</field> | ||
| <field name="report_name">survey.xlsx</field> | ||
| <field name="report_file">survey</field> | ||
| <field name="attachment_use">False</field> | ||
| <field name="binding_model_id" ref="survey.model_survey_survey" /> | ||
| <field name="binding_type">report</field> | ||
| </record> | ||
| </odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.