diff --git a/survey_export_xlsx/README.rst b/survey_export_xlsx/README.rst new file mode 100644 index 000000000..c79477544 --- /dev/null +++ b/survey_export_xlsx/README.rst @@ -0,0 +1,47 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +Survey XLSX Report +================== +This module helps to export survey answers in XLSX format. + +Configuration +============= +Nothing to configure. + +License +------- +Lesser General Public License, Version 3 (LGPL v3) +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +Developer: (V17) Ajith V, + (V16) Albin P J, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/survey_export_xlsx/__init__.py b/survey_export_xlsx/__init__.py new file mode 100644 index 000000000..30507db9e --- /dev/null +++ b/survey_export_xlsx/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import controllers +from . import models +from . import wizard diff --git a/survey_export_xlsx/__manifest__.py b/survey_export_xlsx/__manifest__.py new file mode 100644 index 000000000..3a23cd917 --- /dev/null +++ b/survey_export_xlsx/__manifest__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +{ + 'name': 'Survey XLSX Report', + 'version': '17.0.1.0.0', + 'category': 'Extra Tools', + 'summary': """This module helps to export survey answers in XLS format""", + 'description': """This module helps to export survey answers in XLS format. + You can easily get the questions and answers of the corresponding user""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base', 'survey', 'contacts'], + 'data': [ + 'security/ir.model.access.csv', + 'data/ir_action_data.xml', + 'wizard/survey_xlsx_report_views.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'survey_export_xlsx/static/src/js/action_manager.js'] + }, + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/survey_export_xlsx/controllers/__init__.py b/survey_export_xlsx/controllers/__init__.py new file mode 100644 index 000000000..c1eaea81e --- /dev/null +++ b/survey_export_xlsx/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import survey_export_xlsx diff --git a/survey_export_xlsx/controllers/survey_export_xlsx.py b/survey_export_xlsx/controllers/survey_export_xlsx.py new file mode 100644 index 000000000..52f0749cb --- /dev/null +++ b/survey_export_xlsx/controllers/survey_export_xlsx.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +import json +from odoo import http +from odoo.http import content_disposition, request, serialize_exception as \ + _serialize_exception +from odoo.tools import html_escape + + +class SurveyXlsReportController(http.Controller): + """This is used for get the xlsx report""" + + @http.route('/xlsx_reports', type='http', auth='user', + methods=['POST'], csrf=False) + def get_report_xlsx(self, model, options, output_format, report_name): + """ + Generate and return an XLSX report for the specified model. + + This method handles the HTTP POST request to generate an XLSX report based on the provided model and options. + The report is generated using the custom `get_xlsx_report` method of the specified model and returned as an HTTP response. + + Args: + model (str): The name of the model for which the report is to be generated. + options (str): A JSON string containing the options for generating the report. + It is parsed into a Python dictionary before being passed to the report generation method. + output_format (str): The format of the output report. + This method currently only supports 'xlsx'. + report_name (str): The desired name of the generated report file. + + Returns: + Response: An HTTP response containing the generated XLSX report. + If an error occurs during the report generation, an error response is returned with the exception details. + + Raises: + Exception: If there is any issue during the report generation, it is caught and returned as a JSON response with an error message. + + Note: + - This route is accessible to authenticated users only. + - CSRF protection is disabled for this route. + - A dummy token is set in the response cookies to meet API expectations. + """ + uid = request.session.uid + report_obj = request.env[model].with_user(uid) + options = json.loads(options) + token = 'dummy-because-api-expects-one' + try: + if output_format == 'xlsx': + response = request.make_response( + None, + headers=[ + ('Content-Type', 'application/vnd.ms-excel'), + ('Content-Disposition', + content_disposition(report_name + '.xlsx')) + ] + ) + report_obj.get_xlsx_report(options, response) + response.set_cookie('fileToken', token) + return response + except Exception as e: + error = { + 'code': 200, + 'message': 'Odoo Server Error', + 'data': _serialize_exception(e) + } + return request.make_response(html_escape(json.dumps(error))) diff --git a/survey_export_xlsx/data/ir_action_data.xml b/survey_export_xlsx/data/ir_action_data.xml new file mode 100644 index 000000000..1717a58fe --- /dev/null +++ b/survey_export_xlsx/data/ir_action_data.xml @@ -0,0 +1,23 @@ + + + + + + Survey XLSX Report + + + code + + action = records.action_print_xlsx_report() + + + + diff --git a/survey_export_xlsx/doc/RELEASE_NOTES.md b/survey_export_xlsx/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..538fe40aa --- /dev/null +++ b/survey_export_xlsx/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 16.09.2024 +#### Version 17.0.1.0.0 +#### ADD + +- Initial commit for Survey XLSX Report diff --git a/survey_export_xlsx/models/__init__.py b/survey_export_xlsx/models/__init__.py new file mode 100644 index 000000000..df1c8dfc1 --- /dev/null +++ b/survey_export_xlsx/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import survey_survey diff --git a/survey_export_xlsx/models/survey_survey.py b/survey_export_xlsx/models/survey_survey.py new file mode 100644 index 000000000..ddb601dda --- /dev/null +++ b/survey_export_xlsx/models/survey_survey.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import models + + +class Survey(models.Model): + """This will return the wizard""" + _inherit = 'survey.survey' + + def action_print_xlsx_report(self): + """Returning the wizard for filtering the report""" + return { + 'name': 'Survey Answer XLSX Report', + 'res_model': 'survey.xlsx.report', + 'view_mode': 'form', + 'view_type': 'form', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': {'default_survey_ids': self.ids}, + } diff --git a/survey_export_xlsx/security/ir.model.access.csv b/survey_export_xlsx/security/ir.model.access.csv new file mode 100644 index 000000000..961c3e40c --- /dev/null +++ b/survey_export_xlsx/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_survey_xlsx_report_user,access.survey.xlsx.report.user,model_survey_xlsx_report,base.group_user,1,1,1,1 diff --git a/survey_export_xlsx/static/description/Icon.png b/survey_export_xlsx/static/description/Icon.png new file mode 100644 index 000000000..32414eaad Binary files /dev/null and b/survey_export_xlsx/static/description/Icon.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/capture (1).png b/survey_export_xlsx/static/description/assets/icons/capture (1).png new file mode 100755 index 000000000..8824deafc Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/capture (1).png differ diff --git a/survey_export_xlsx/static/description/assets/icons/check.png b/survey_export_xlsx/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/check.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/chevron.png b/survey_export_xlsx/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/chevron.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/cogs.png b/survey_export_xlsx/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/cogs.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/consultation.png b/survey_export_xlsx/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/consultation.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/ecom-black.png b/survey_export_xlsx/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/ecom-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/education-black.png b/survey_export_xlsx/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/education-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/hotel-black.png b/survey_export_xlsx/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/hotel-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/img.png b/survey_export_xlsx/static/description/assets/icons/img.png new file mode 100755 index 000000000..70197f477 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/img.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/license.png b/survey_export_xlsx/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/license.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/lifebuoy.png b/survey_export_xlsx/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/lifebuoy.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/manufacturing-black.png b/survey_export_xlsx/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/manufacturing-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/photo-capture.png b/survey_export_xlsx/static/description/assets/icons/photo-capture.png new file mode 100755 index 000000000..06c111758 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/photo-capture.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/pos-black.png b/survey_export_xlsx/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/pos-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/puzzle.png b/survey_export_xlsx/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/puzzle.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/restaurant-black.png b/survey_export_xlsx/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/restaurant-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/service-black.png b/survey_export_xlsx/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/service-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/trading-black.png b/survey_export_xlsx/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/trading-black.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/training.png b/survey_export_xlsx/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/training.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/update.png b/survey_export_xlsx/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/update.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/user.png b/survey_export_xlsx/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/user.png differ diff --git a/survey_export_xlsx/static/description/assets/icons/wrench.png b/survey_export_xlsx/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/survey_export_xlsx/static/description/assets/icons/wrench.png differ diff --git a/survey_export_xlsx/static/description/assets/misc/Cybrosys R.png b/survey_export_xlsx/static/description/assets/misc/Cybrosys R.png new file mode 100755 index 000000000..da4058087 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/misc/Cybrosys R.png differ diff --git a/survey_export_xlsx/static/description/assets/misc/email.svg b/survey_export_xlsx/static/description/assets/misc/email.svg new file mode 100755 index 000000000..15291cdc3 --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/survey_export_xlsx/static/description/assets/misc/phone.svg b/survey_export_xlsx/static/description/assets/misc/phone.svg new file mode 100755 index 000000000..b7bd7f251 --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/survey_export_xlsx/static/description/assets/misc/star (1) 2.svg b/survey_export_xlsx/static/description/assets/misc/star (1) 2.svg new file mode 100755 index 000000000..5ae9f507a --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/survey_export_xlsx/static/description/assets/misc/support (1) 1.svg b/survey_export_xlsx/static/description/assets/misc/support (1) 1.svg new file mode 100755 index 000000000..7d37a8f30 --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/survey_export_xlsx/static/description/assets/misc/support-email.svg b/survey_export_xlsx/static/description/assets/misc/support-email.svg new file mode 100755 index 000000000..eb70370d6 --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/survey_export_xlsx/static/description/assets/misc/tick-mark.svg b/survey_export_xlsx/static/description/assets/misc/tick-mark.svg new file mode 100755 index 000000000..2dbb40187 --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/survey_export_xlsx/static/description/assets/misc/whatsapp 1.svg b/survey_export_xlsx/static/description/assets/misc/whatsapp 1.svg new file mode 100755 index 000000000..0bfaf8fc6 --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/survey_export_xlsx/static/description/assets/misc/whatsapp.svg b/survey_export_xlsx/static/description/assets/misc/whatsapp.svg new file mode 100755 index 000000000..b618aea1d --- /dev/null +++ b/survey_export_xlsx/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/survey_export_xlsx/static/description/assets/modules/l1.png b/survey_export_xlsx/static/description/assets/modules/l1.png new file mode 100755 index 000000000..f0a869b5d Binary files /dev/null and b/survey_export_xlsx/static/description/assets/modules/l1.png differ diff --git a/survey_export_xlsx/static/description/assets/modules/l2.png b/survey_export_xlsx/static/description/assets/modules/l2.png new file mode 100755 index 000000000..070924079 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/modules/l2.png differ diff --git a/survey_export_xlsx/static/description/assets/modules/l3.png b/survey_export_xlsx/static/description/assets/modules/l3.png new file mode 100755 index 000000000..d17ef8819 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/modules/l3.png differ diff --git a/survey_export_xlsx/static/description/assets/modules/l4.png b/survey_export_xlsx/static/description/assets/modules/l4.png new file mode 100755 index 000000000..befe2d943 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/modules/l4.png differ diff --git a/survey_export_xlsx/static/description/assets/modules/l5.png b/survey_export_xlsx/static/description/assets/modules/l5.png new file mode 100755 index 000000000..74c223ff1 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/modules/l5.png differ diff --git a/survey_export_xlsx/static/description/assets/modules/l6.png b/survey_export_xlsx/static/description/assets/modules/l6.png new file mode 100755 index 000000000..b67758f10 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/modules/l6.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/1.png b/survey_export_xlsx/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..045fb0b6a Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/1.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/2.png b/survey_export_xlsx/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..73794fd9d Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/2.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/3.png b/survey_export_xlsx/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..e329bd84a Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/3.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/4.png b/survey_export_xlsx/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..9e1ed6ffc Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/4.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/5.png b/survey_export_xlsx/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..06832c63b Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/5.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/6.png b/survey_export_xlsx/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..387d96371 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/6.png differ diff --git a/survey_export_xlsx/static/description/assets/screenshots/Gif.gif b/survey_export_xlsx/static/description/assets/screenshots/Gif.gif new file mode 100644 index 000000000..c13cafcb1 Binary files /dev/null and b/survey_export_xlsx/static/description/assets/screenshots/Gif.gif differ diff --git a/survey_export_xlsx/static/description/banner.jpg b/survey_export_xlsx/static/description/banner.jpg new file mode 100644 index 000000000..a757d6e03 Binary files /dev/null and b/survey_export_xlsx/static/description/banner.jpg differ diff --git a/survey_export_xlsx/static/description/index.html b/survey_export_xlsx/static/description/index.html new file mode 100755 index 000000000..25908c0e9 --- /dev/null +++ b/survey_export_xlsx/static/description/index.html @@ -0,0 +1,737 @@ + + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+
+
+
+

+ Survey XLSX Report

+

+ This Module helps to Export Survey Answers in XLSX Format. + You can easily get the Questions and Answers of the + Corresponding User +

+
+ +
+
+
+
+
+

+ Key Highlights +

+
+
+
+
+
+ +
+
+

+ You can Filter the Survey Questions and Answers + based on User.

+
+
+
+
+
+
+ +
+
+

+ You can get Questions and Answers in Tree/Form + views.

+
+
+
+
+
+
+ +
+
+

+ Also, You can get Filtered Reports of all Survey + Questions and Answers from the Tree view.

+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+

+ Button In Tree View +

+
+
+
+
+
+
+ +
+
+

+ Button In Form View +

+
+
+
+
+
+
+ +
+
+

+ Get User Specific Report +

+

You can see the option to add users. Also, + you can add a user, and it will give a + survey questions and answers based on the + user.

+
+
+
+
+
+
+ +
+
+

+ Get All Users Report +

+

If you haven't chosen any user, you will get + survey questions and answers from all + users.

+
+
+
+
+
+
+ +
+
+

+ Survey XLSX Reports +

+
+
+
+
+
+
+
    +
  • + You can Filter + the Survey Questions and Answers based on User. +
  • +
  • + You can get + Questions and Answers in Tree/Form views. +
  • +
  • + Also, You can + get Filtered Reports of all Survey Questions and + Answers from the Tree view. +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:16th September 2024 +
+

+ Initial Commit for Survey XLSX Report

+
+
+
+
+
+
+
+

+ Related Products

+
+
+ +
+
+

+ Our Services

+ +
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire + Odoo Developer

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Licensing Consultancy

+
+
+
+
+
+
+

+ Our Industries

+ +
+
+
+
+
+
+ +

Trading

+

Easily procure and sell your products

+
+
+
+
+ +

POS

+

Easy configuration and convivial experience

+
+
+
+
+ +

+ Education

+

A platform for educational management

+
+
+
+
+ +

+ Manufacturing

+

Plan, track and schedule your operations

+
+
+
+
+ +

E-commerce & + Website

+

Mobile friendly, awe-inspiring product pages

+
+
+
+
+ +

Service + Management

+

Keep track of services and invoice

+
+
+
+
+ +

+ Restaurant

+

Run your bar or restaurant methodically

+
+
+
+
+ +

Hotel + Management

+

An all-inclusive hotel management application

+
+
+
+
+
+
+

+ Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got + questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to + us on WhatsApp!

+
+91 + 99456767686 +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/survey_export_xlsx/static/src/js/action_manager.js b/survey_export_xlsx/static/src/js/action_manager.js new file mode 100644 index 000000000..0abe7f257 --- /dev/null +++ b/survey_export_xlsx/static/src/js/action_manager.js @@ -0,0 +1,16 @@ +/** @odoo-module **/ +import { registry } from "@web/core/registry"; +import { BlockUI } from "@web/core/ui/block_ui"; +import { download } from "@web/core/network/download"; +//this is used to call the controller and also passes the report data. +registry.category("ir.actions.report handlers").add("xlsx", async function (action) { + if (action.report_type === 'xlsx') { + BlockUI; + await download({ + url: '/xlsx_reports', + data: action.data, + complete: () => unblockUI, + error: (error) => this.call('crash_manager', 'rpc_error', error), + }); + } +}); diff --git a/survey_export_xlsx/wizard/__init__.py b/survey_export_xlsx/wizard/__init__.py new file mode 100644 index 000000000..f832cbc6d --- /dev/null +++ b/survey_export_xlsx/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import survey_xlsx_report diff --git a/survey_export_xlsx/wizard/survey_xlsx_report.py b/survey_export_xlsx/wizard/survey_xlsx_report.py new file mode 100644 index 000000000..b3d465750 --- /dev/null +++ b/survey_export_xlsx/wizard/survey_xlsx_report.py @@ -0,0 +1,239 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Ajith V (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +################################################################################ +import io +import xlsxwriter +from odoo import api, fields, models, _ +from odoo.tools import date_utils +from odoo.tools.safe_eval import json +from odoo.exceptions import ValidationError + + +class SurveyXlsReport(models.TransientModel): + """This is the wizard model, We can filter the xls report using this + model""" + _name = 'survey.xlsx.report' + _description = 'Survey XLSX Report ' + + partner_id = fields.Many2one('res.partner', string="Partner", + help="Select for getting the report of the " + "user") + survey_ids = fields.Many2many('survey.survey', string="Survey Ids", + help="This field stores survey ids", + readonly=True) + + @api.onchange('partner_id') + def _onchange_partner_id(self): + """ + Updates the domain of the 'partner_id' field based on the partners + who have completed the associated surveys. + + This method iterates over the survey records linked to the current record + and searches for survey user inputs that are in a 'done' state. It collects + the partners associated with these completed surveys and sets the domain + for the 'partner_id' field accordingly. + + If no partners have completed the surveys, a ValidationError is raised. + + Raises: + ValidationError: If no partners have participated in the survey. + + Returns: + dict: A dictionary containing the domain for the 'partner_id' field, + limited to the IDs of partners who have completed the surveys. + """ + partner_ids = [] + for rec in self.survey_ids: + user_list = self.env['survey.user_input'].search( + [('survey_id', '=', rec._origin.id), ('state', '=', 'done')]) + for dec in user_list.partner_id: + if dec.id not in partner_ids: + partner_ids.append(dec.id) + if not partner_ids: + raise ValidationError(_( + "There are no partners participating in this survey")) + + return {'domain': {'partner_id': [('id', 'in', partner_ids)]}} + + def action_print_survey_xlsx_report(self): + """ + Generates and returns an XLSX report containing survey responses. + + This method is triggered by a button and compiles survey data into an + Excel file. It iterates through all linked surveys, filters completed + responses (in the 'done' state), and gathers relevant information such + as survey name, creation date, respondent's name, question title, and + corresponding answers. + + The collected data is organized by survey name and structured into a + dictionary format, which is then passed to the report generation process. + + If a specific partner is selected, the method filters the survey + responses to include only those from that partner. + + Returns: + dict: An action that triggers the generation of an XLSX report with + the compiled survey data. + + The returned action dictionary includes: + - 'type': Specifies the type of action (report generation). + - 'data': Contains model name, options (including the formatted survey data), + output format, and report name. + - 'report_type': Specifies the report type ('xlsx'). + """ + data_dict = {} + + for doc in self.survey_ids: + domain = [('survey_id', '=', doc.id), ('state', '=', 'done')] + if self.partner_id: + domain.append(('partner_id', '=', self.partner_id.id)) + for record in self.env['survey.user_input'].search(domain): + for rec in self.env['survey.user_input.line'].search( + [('user_input_id', '=', record.id)]): + data = { + 'survey_name': rec.survey_id.title, + 'create_date': rec.create_date, + 'user_name': rec.user_input_id.partner_id.name, + 'question': rec.question_id.title, + 'answer': rec.display_name, + } + # Check if the survey_name is already in the dictionary + survey_name = data['survey_name'] + if survey_name not in data_dict: + data_dict[ + survey_name] = [] + data_dict[survey_name].append(data) + grouped_data_list = [ + {'survey_name': survey_name, 'partner_id': self.partner_id.name, + 'data': survey_data} for survey_name, survey_data in + data_dict.items()] + dict_data = { + 'record': grouped_data_list + } + return { + 'type': 'ir.actions.report', + 'data': { + 'model': 'survey.xlsx.report', + 'options': json.dumps(dict_data, + default=date_utils.json_default), + 'output_format': 'xlsx', + 'report_name': 'Survey Question Answer Report', + }, + 'report_type': 'xlsx', + } + + def get_xlsx_report(self, dict_data, response): + """ + Generates an XLSX report from the provided data and writes it to the response. + + This method is responsible for creating an Excel report using the `xlsxwriter` + library. It processes the survey data contained in `dict_data` and formats it + into a structured XLSX report. The report includes details such as survey name, + respondent name, response date, questions, and answers. + + Parameters: + dict_data (dict): A dictionary containing the survey data to be included + in the report. The dictionary should have a key 'record' + which holds a list of survey response data. + response (werkzeug.wrappers.Response): The HTTP response object where the + generated XLSX file will be written. + + The report's layout adjusts based on whether a specific partner is associated + with the survey responses. If a partner is selected, the report will include + the partner's name; otherwise, it will show general response data. + + The method does the following: + - Creates an in-memory XLSX file. + - Adds survey data to the worksheet. + - Applies formatting to the headers and cells. + - Writes the final XLSX file to the response stream. + + Returns: + None: The function directly writes the XLSX report to the response object. + """ + output = io.BytesIO() + workbook = xlsxwriter.Workbook(output, {'in_memory': True}) + sheet = workbook.add_worksheet() + format21 = workbook.add_format({'font_size': 10, 'bold': True}) + font_size_8 = workbook.add_format({'font_size': 8}) + head = workbook.add_format( + {'align': 'center', 'bold': True, 'font_size': '20px'}) + heading_row_height = 30 + if dict_data.get('record'): + if dict_data['record']: + row = 0 + for records in dict_data.get('record'): + sheet.write(row, 0, records['survey_name'], head) + sheet.set_row(sheet.dim_rowmax, heading_row_height) + sheet.merge_range(sheet.dim_rowmax, 0, sheet.dim_rowmax, 4, + records['survey_name'], + head) + row += 1 + if not records.get('partner_id'): + sheet.set_column('A:A', 5) + sheet.set_column('B:B', 15) + sheet.set_column('C:C', 15) + sheet.set_column('D:D', 76) + sheet.set_column('E:E', 56) + sheet.write(row, 0, 'Sl no', format21) + sheet.write(row, 1, 'Name', format21) + sheet.write(row, 2, 'Date', format21) + sheet.write(row, 3, 'Question', format21) + sheet.write(row, 4, 'Answer', format21) + row += 1 + a = 1 + for datas in records.get('data'): + sheet.write(row, 0, a, font_size_8) + a = a + 1 + sheet.write(row, 1, datas.get('user_name'), + font_size_8) + sheet.write(row, 2, datas.get('create_date'), + font_size_8) + sheet.write(row, 3, datas.get('question'), + font_size_8) + sheet.write(row, 4, datas.get('answer'), + font_size_8) + row += 1 + else: + sheet.set_column('A:A', 5) + sheet.set_column('B:B', 15) + sheet.set_column('C:C', 76) + sheet.set_column('D:D', 56) + sheet.write(row, 0, 'Sl no', format21) + sheet.write(row, 1, 'Date', format21) + sheet.write(row, 2, 'Question', format21) + sheet.write(row, 3, 'Answer', format21) + row += 1 + a = 1 + for datas in records.get('data'): + sheet.write(row, 0, a, font_size_8) + a = a + 1 + sheet.write(row, 1, datas.get('create_date'), + font_size_8) + sheet.write(row, 2, datas.get('question'), + font_size_8) + sheet.write(row, 3, datas.get('answer'), + font_size_8) + row += 1 + workbook.close() + output.seek(0) + response.stream.write(output.read()) + output.close() diff --git a/survey_export_xlsx/wizard/survey_xlsx_report_views.xml b/survey_export_xlsx/wizard/survey_xlsx_report_views.xml new file mode 100644 index 000000000..ee3e40143 --- /dev/null +++ b/survey_export_xlsx/wizard/survey_xlsx_report_views.xml @@ -0,0 +1,38 @@ + + + + + survey.xlsx.report.view.form + survey.xlsx.report + +
+ + + + + + + +
+
+
+