diff --git a/mis_builder_wizard_export_xlsx/README.rst b/mis_builder_wizard_export_xlsx/README.rst new file mode 100644 index 0000000..d6fe438 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/README.rst @@ -0,0 +1,88 @@ +============================== +Mis Builder Wizard Export Xlsx +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7d619af62e93a1182c42c86d76e37a8fceec986f794aaa8b79b32d69062fc8c5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmis--builder--contrib-lightgray.png?logo=github + :target: https://github.com/OCA/mis-builder-contrib/tree/16.0/mis_builder_wizard_export_xlsx + :alt: OCA/mis-builder-contrib +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/mis-builder-contrib-16-0/mis-builder-contrib-16-0-mis_builder_wizard_export_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/mis-builder-contrib&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This modules allows user to add some options when exporting some MIS +reports to xlsx: + +- Generate multiple reports as sheets in one xlsx. +- Selecting custom pivot dates for each report. +- Computing one report for multiple companies but having one sheet per + company as if we executed multiple times the export. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Action 'Custom Export XLS' in ``Accounting>Reporting>MIS Reports`` to +open the wizard to export to xlsx. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Zina Rasoamanana zina.rasoamanana@acsone.eu (https://www.acsone.eu/) + +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/mis-builder-contrib `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mis_builder_wizard_export_xlsx/__init__.py b/mis_builder_wizard_export_xlsx/__init__.py new file mode 100644 index 0000000..aee8895 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/mis_builder_wizard_export_xlsx/__manifest__.py b/mis_builder_wizard_export_xlsx/__manifest__.py new file mode 100644 index 0000000..f24bd0e --- /dev/null +++ b/mis_builder_wizard_export_xlsx/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Mis Builder Wizard Export Xlsx", + "summary": """ + Wizard to select various options when exporting a mis report as xlsx""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/mis-builder-contrib", + "depends": [ + "mis_builder", + ], + "data": [ + "security/mis_builder_custom_export_xls_wizard.xml", + "security/mis_builder_custom_export_xls_wizard_line.xml", + "wizards/mis_builder_custom_export_xls_wizard.xml", + ], + "demo": [], +} diff --git a/mis_builder_wizard_export_xlsx/models/__init__.py b/mis_builder_wizard_export_xlsx/models/__init__.py new file mode 100644 index 0000000..abfeb2d --- /dev/null +++ b/mis_builder_wizard_export_xlsx/models/__init__.py @@ -0,0 +1,2 @@ +from . import mis_report_instance +from . import report_mis_builder_mis_report_instance_xlsx diff --git a/mis_builder_wizard_export_xlsx/models/mis_report_instance.py b/mis_builder_wizard_export_xlsx/models/mis_report_instance.py new file mode 100644 index 0000000..4db1dea --- /dev/null +++ b/mis_builder_wizard_export_xlsx/models/mis_report_instance.py @@ -0,0 +1,27 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class MisReportInstance(models.Model): + + _inherit = "mis.report.instance" + + def open_wizard_custom_export_xls(self): + return self.env["ir.actions.act_window"]._for_xml_id( + "mis_builder_wizard_export_xlsx.mis_builder_custom_export_xls_wizard_act_window" + ) + + def _compute_pivot_date(self): + ret = super()._compute_pivot_date() + report_id_by_pivot_date = self.env.context.get( + "mis_builder_xls_report_id_by_pivot_date" + ) + if report_id_by_pivot_date: + for rec in self: + pivot_date = report_id_by_pivot_date.get(str(rec.id)) + if pivot_date: + rec.pivot_date = pivot_date + + return ret diff --git a/mis_builder_wizard_export_xlsx/models/report_mis_builder_mis_report_instance_xlsx.py b/mis_builder_wizard_export_xlsx/models/report_mis_builder_mis_report_instance_xlsx.py new file mode 100644 index 0000000..fd92e81 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/models/report_mis_builder_mis_report_instance_xlsx.py @@ -0,0 +1,30 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class MisBuilderXlsx(models.AbstractModel): + + _inherit = "report.mis_builder.mis_report_instance_xlsx" + + def generate_xlsx_report(self, workbook, data, objects): + company_ids = self.env.context.get("mis_builder_xls_custom_company_ids") + if company_ids: + if self.env.context.get("mis_builder_xls_company_by_company"): + for company_id in company_ids: + res = super().generate_xlsx_report( + workbook, + data, + objects.with_context(**{"allowed_company_ids": [company_id]}), + ) + else: + res = super().generate_xlsx_report( + workbook, + data, + objects.with_context(**{"allowed_company_ids": company_ids}), + ) + else: + res = super().generate_xlsx_report(workbook, data, objects) + + return res diff --git a/mis_builder_wizard_export_xlsx/readme/CONTRIBUTORS.md b/mis_builder_wizard_export_xlsx/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..b0d3087 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Zina Rasoamanana (https://www.acsone.eu/) diff --git a/mis_builder_wizard_export_xlsx/readme/DESCRIPTION.md b/mis_builder_wizard_export_xlsx/readme/DESCRIPTION.md new file mode 100644 index 0000000..180c818 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This modules allows user to add some options when exporting some MIS reports to xlsx: + - Generate multiple reports as sheets in one xlsx. + - Selecting custom pivot dates for each report. + - Computing one report for multiple companies but having one sheet per company as if we executed multiple times the export. diff --git a/mis_builder_wizard_export_xlsx/readme/USAGE.md b/mis_builder_wizard_export_xlsx/readme/USAGE.md new file mode 100644 index 0000000..ff6f1f0 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/readme/USAGE.md @@ -0,0 +1 @@ +Action 'Custom Export XLS' in `Accounting>Reporting>MIS Reports` to open the wizard to export to xlsx. \ No newline at end of file diff --git a/mis_builder_wizard_export_xlsx/security/mis_builder_custom_export_xls_wizard.xml b/mis_builder_wizard_export_xlsx/security/mis_builder_custom_export_xls_wizard.xml new file mode 100644 index 0000000..fb1eac5 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/security/mis_builder_custom_export_xls_wizard.xml @@ -0,0 +1,16 @@ + + + + + + mis.builder.custom.export.xls.wizard access + + + + + + + + + diff --git a/mis_builder_wizard_export_xlsx/security/mis_builder_custom_export_xls_wizard_line.xml b/mis_builder_wizard_export_xlsx/security/mis_builder_custom_export_xls_wizard_line.xml new file mode 100644 index 0000000..ea7032e --- /dev/null +++ b/mis_builder_wizard_export_xlsx/security/mis_builder_custom_export_xls_wizard_line.xml @@ -0,0 +1,19 @@ + + + + + + mis.builder.custom.export.xls.wizard.line access + + + + + + + + + diff --git a/mis_builder_wizard_export_xlsx/static/description/icon.png b/mis_builder_wizard_export_xlsx/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/mis_builder_wizard_export_xlsx/static/description/icon.png differ diff --git a/mis_builder_wizard_export_xlsx/static/description/index.html b/mis_builder_wizard_export_xlsx/static/description/index.html new file mode 100644 index 0000000..7557c3b --- /dev/null +++ b/mis_builder_wizard_export_xlsx/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +Mis Builder Wizard Export Xlsx + + + +
+

Mis Builder Wizard Export Xlsx

+ + +

Beta License: AGPL-3 OCA/mis-builder-contrib Translate me on Weblate Try me on Runboat

+

This modules allows user to add some options when exporting some MIS +reports to xlsx:

+
    +
  • Generate multiple reports as sheets in one xlsx.
  • +
  • Selecting custom pivot dates for each report.
  • +
  • Computing one report for multiple companies but having one sheet per +company as if we executed multiple times the export.
  • +
+

Table of contents

+ +
+

Usage

+

Action ‘Custom Export XLS’ in Accounting>Reporting>MIS Reports to +open the wizard to export to xlsx.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/mis-builder-contrib project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mis_builder_wizard_export_xlsx/wizards/__init__.py b/mis_builder_wizard_export_xlsx/wizards/__init__.py new file mode 100644 index 0000000..19b1b4d --- /dev/null +++ b/mis_builder_wizard_export_xlsx/wizards/__init__.py @@ -0,0 +1,2 @@ +from . import mis_builder_custom_export_xls_wizard +from . import mis_builder_custom_export_xlsx_wizard_line diff --git a/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xls_wizard.py b/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xls_wizard.py new file mode 100644 index 0000000..bc4f656 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xls_wizard.py @@ -0,0 +1,58 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import Command, api, fields, models + + +class MisBuilderCustomExportXlsWizard(models.TransientModel): + _name = "mis.builder.custom.export.xls.wizard" + _description = "Mis Builder Custom Export Xls Wizard" + + company_ids = fields.Many2many( + comodel_name="res.company", + string="Company", + domain="[('id', 'in', allowed_company_ids)]", + default=lambda self: self.env.company, + ) + + wizard_line_ids = fields.One2many( + comodel_name="mis.builder.custom.export.xls.wizard.line", + inverse_name="wizard_id", + ) + + compute_report_company_by_company = fields.Boolean( + help="Compute report company by company (one sheet by company and report) instead of" + " computing computing report one every company at once (one sheet by report)." + ) + + @api.model + def default_get(self, fields_list): + res = super().default_get(fields_list) + report_ids = self.env.context.get("active_ids") + if self.env.context.get("active_model") == "mis.report.instance" and ( + report_ids + ): + res["wizard_line_ids"] = [ + Command.create( + { + "report_id": report_id, + } + ) + for report_id in report_ids + ] + + return res + + def export(self): + custom_context = { + "mis_builder_xls_custom_company_ids": self.company_ids.ids, + "mis_builder_xls_report_id_by_pivot_date": { + rec.report_id.id: rec.date for rec in self.wizard_line_ids + }, + "mis_builder_xls_company_by_company": self.compute_report_company_by_company, + } + + # map date by instance + return self.wizard_line_ids.report_id.with_context( + **custom_context + ).export_xls() diff --git a/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xls_wizard.xml b/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xls_wizard.xml new file mode 100644 index 0000000..12c7370 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xls_wizard.xml @@ -0,0 +1,64 @@ + + + + + + mis.builder.custom.export.xls.wizard.form (in ebt_mis_builder_custom_export_xls) + mis.builder.custom.export.xls.wizard + +
+ + + + + + + + + + + +
+
+
+
+
+ + + Mis Builder Custom Export Xls Wizard + mis.builder.custom.export.xls.wizard + form + {} + new + + + + Custom Export XLS + + + list + code + + action = records.open_wizard_custom_export_xls() + + + + +
diff --git a/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xlsx_wizard_line.py b/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xlsx_wizard_line.py new file mode 100644 index 0000000..04d2e67 --- /dev/null +++ b/mis_builder_wizard_export_xlsx/wizards/mis_builder_custom_export_xlsx_wizard_line.py @@ -0,0 +1,30 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class MisBuilderCustomExportXlsWizardLine(models.TransientModel): + _name = "mis.builder.custom.export.xls.wizard.line" + _description = "Mis Builder Custom Export Xls Wizard Line" + + report_id = fields.Many2one( + comodel_name="mis.report.instance", + string="Report", + readonly=False, + ) + + date = fields.Date( + compute="_compute_date", + store=True, + readonly=False, + ) + + wizard_id = fields.Many2one( + comodel_name="mis.builder.custom.export.xls.wizard", + ) + + @api.depends("report_id") + def _compute_date(self): + for rec in self: + rec.date = rec.report_id.pivot_date diff --git a/setup/mis_builder_wizard_export_xlsx/odoo/addons/mis_builder_wizard_export_xlsx b/setup/mis_builder_wizard_export_xlsx/odoo/addons/mis_builder_wizard_export_xlsx new file mode 120000 index 0000000..d6b645d --- /dev/null +++ b/setup/mis_builder_wizard_export_xlsx/odoo/addons/mis_builder_wizard_export_xlsx @@ -0,0 +1 @@ +../../../../mis_builder_wizard_export_xlsx \ No newline at end of file diff --git a/setup/mis_builder_wizard_export_xlsx/setup.py b/setup/mis_builder_wizard_export_xlsx/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/mis_builder_wizard_export_xlsx/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)