diff --git a/mis_template_financial_report/README.rst b/mis_template_financial_report/README.rst new file mode 100644 index 00000000..d09e6130 --- /dev/null +++ b/mis_template_financial_report/README.rst @@ -0,0 +1,93 @@ +=========================================== +Profit & Loss / Balance sheet MIS templates +=========================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Faccount--financial--reporting--lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-reporting/tree/12.0/mis_template_financial_report + :alt: OCA/account-financial-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-reporting-12-0/account-financial-reporting-12-0-mis_template_financial_report + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/176/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon provides MIS builder templates to generate Dutch style Profit&Loss and Balance Sheet reports. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Select one of the `Profit & Loss` or `Balance Sheet` templates in a new MIS report. + +For details, refer to the `MIS Builder documentation `_ + +Known issues / Roadmap +====================== + +* support horizontal mode for xslx export + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Hunki Enterprises BV + +Contributors +~~~~~~~~~~~~ + +* Holger Brunn (https://hunki-enterprises.nl) + +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. + +.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px + :target: https://github.com/hbrunn + :alt: hbrunn + +Current `maintainer `__: + +|maintainer-hbrunn| + +This module is part of the `OCA/account-financial-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mis_template_financial_report/__init__.py b/mis_template_financial_report/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/mis_template_financial_report/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mis_template_financial_report/__manifest__.py b/mis_template_financial_report/__manifest__.py new file mode 100644 index 00000000..9bc8601f --- /dev/null +++ b/mis_template_financial_report/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2020 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Profit & Loss / Balance sheet MIS templates", + "version": "12.0.1.1.0", + "license": "AGPL-3", + "author": "Hunki Enterprises BV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-reporting", + "category": "Localization", + "depends": ["mis_builder"], + "data": [ + "data/mis_report_style.xml", + "data/mis_report.xml", + "data/mis_report_kpi.xml", + "data/mis_report_subreport.xml", + "views/templates.xml", + ], + "qweb": ["static/src/xml/mis_template_financial_report.xml"], + "maintainers": ["hbrunn"], +} diff --git a/mis_template_financial_report/data/mis_report.xml b/mis_template_financial_report/data/mis_report.xml new file mode 100644 index 00000000..f1ee88b2 --- /dev/null +++ b/mis_template_financial_report/data/mis_report.xml @@ -0,0 +1,10 @@ + + + Profit & Loss + + + + Balance Sheet + + + diff --git a/mis_template_financial_report/data/mis_report_kpi.xml b/mis_template_financial_report/data/mis_report_kpi.xml new file mode 100644 index 00000000..b4d98807 --- /dev/null +++ b/mis_template_financial_report/data/mis_report_kpi.xml @@ -0,0 +1,103 @@ + + + loss + Loss + balp[('user_type_id', 'in', (ref('account.data_account_type_depreciation').id, ref('account.data_account_type_expenses').id, ref('account.data_account_type_direct_costs').id))][] + true + + + num + diff + sum + 100 + + + + profit + Profit + -balp[('user_type_id', 'in', (ref('account.data_account_type_revenue').id, ref('account.data_account_type_other_income').id, ref('account.data_unaffected_earnings').id))][] + true + + + num + diff + sum + 0 + + + + 3 + pl_to_report + Profit or loss to report + profit - loss + false + + num + diff + none + 101 + + + + 8 + liability_header + Liability + liability + subreport_pl.pl_to_report + false + + num + none + none + 100 + + + + 7 + pl + Profit / Loss + subreport_pl.pl_to_report + false + + num + pct + sum + 102 + + + + 5 + liability + Liabilities + -bale[('user_type_id', 'in', (ref('account.data_account_type_payable').id, ref('account.data_account_type_current_liabilities').id, ref('account.data_account_type_non_current_liabilities').id, ref('account.data_account_type_equity').id))][] + true + + + num + diff + sum + 101 + + + + 4 + assets + Assets + bale[('user_type_id', 'in', (ref('account.data_account_type_receivable').id, ref('account.data_account_type_liquidity').id, ref('account.data_account_type_current_assets').id, ref('account.data_account_type_non_current_assets').id, ref('account.data_account_type_fixed_assets').id))][] + true + + + num + diff + sum + 0 + + + diff --git a/mis_template_financial_report/data/mis_report_style.xml b/mis_template_financial_report/data/mis_report_style.xml new file mode 100644 index 00000000..3ba409f0 --- /dev/null +++ b/mis_template_financial_report/data/mis_report_style.xml @@ -0,0 +1,31 @@ + + + PL/BS default + false + 2 + false + true + + + PL/BS header + false + bold + + + PL/BS double indented details + false + 2 + + + PL/BS indented header + false + bold + false + 1 + + + PL/BS details + false + 1 + + diff --git a/mis_template_financial_report/data/mis_report_subreport.xml b/mis_template_financial_report/data/mis_report_subreport.xml new file mode 100644 index 00000000..dc848768 --- /dev/null +++ b/mis_template_financial_report/data/mis_report_subreport.xml @@ -0,0 +1,7 @@ + + + + + subreport_pl + + diff --git a/mis_template_financial_report/models/__init__.py b/mis_template_financial_report/models/__init__.py new file mode 100644 index 00000000..5f14fa3b --- /dev/null +++ b/mis_template_financial_report/models/__init__.py @@ -0,0 +1 @@ +from . import mis_report_instance diff --git a/mis_template_financial_report/models/mis_report_instance.py b/mis_template_financial_report/models/mis_report_instance.py new file mode 100644 index 00000000..2c23d4ce --- /dev/null +++ b/mis_template_financial_report/models/mis_report_instance.py @@ -0,0 +1,81 @@ +# Copyright 2020 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import copy +from collections import OrderedDict + +from odoo import api, models + + +class MisReportInstance(models.Model): + _inherit = "mis.report.instance" + + @api.multi + def compute(self): + if not self._is_horizontal(): + return super().compute() + + full_matrix = self._compute_matrix() + + matrices = self._compute_horizontal_matrices(full_matrix) + + result = full_matrix.as_dict() + result["horizontal_matrices"] = [ + extra_matrix.as_dict() for extra_matrix in matrices + ] + + return result + + @api.multi + def _is_horizontal(self): + """Determine if the report template is a horizontal one""" + self.ensure_one() + return set(self.report_id.get_external_id().values()) & { + "mis_template_financial_report.report_bs", + "mis_template_financial_report.report_pl", + } + + @api.multi + def _compute_horizontal_matrices(self, matrix=None): + """Compute the matrix (if not passed) and return the split versions""" + return self._split_matrix( + matrix or self._compute_matrix(), + [ + ( + self.env.ref("mis_template_financial_report.kpi_profit"), + self.env.ref("mis_template_financial_report.kpi_pl_to_report"), + self.env.ref("mis_template_financial_report.kpi_assets"), + ) + ], + ) + + @api.multi + def _split_matrix(self, original_matrix, kpi_defs=None, keep_remaining=True): + """Split a matrix by duplicating it as shallowly as possible and removing + rows according to kpi_defs + + KPIs not listed there will end up together in the last matrix if + `keep_remaining` is set. + + :param kpi_defs: [(kpi_first_matrix1, ...), (kpi_second_matrix1, ...)] + :return: list of KpiMatrix + """ + result = [] + remaining_rows = original_matrix._kpi_rows.copy() + + for kpis in kpi_defs: + matrix = copy.copy(original_matrix) + matrix._kpi_rows = OrderedDict( + [ + (kpi, remaining_rows.pop(kpi)) + for kpi in kpis + if kpi in remaining_rows + ] + ) + result.append(matrix) + + if remaining_rows and keep_remaining: + matrix = copy.copy(original_matrix) + matrix._kpi_rows = remaining_rows + result.append(matrix) + + return result diff --git a/mis_template_financial_report/readme/CONTRIBUTORS.rst b/mis_template_financial_report/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..5429cc97 --- /dev/null +++ b/mis_template_financial_report/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Holger Brunn (https://hunki-enterprises.nl) diff --git a/mis_template_financial_report/readme/DESCRIPTION.rst b/mis_template_financial_report/readme/DESCRIPTION.rst new file mode 100644 index 00000000..15e8480f --- /dev/null +++ b/mis_template_financial_report/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This addon provides MIS builder templates to generate generic Profit & Loss and Balance Sheet reports. diff --git a/mis_template_financial_report/readme/ROADMAP.rst b/mis_template_financial_report/readme/ROADMAP.rst new file mode 100644 index 00000000..d5786edd --- /dev/null +++ b/mis_template_financial_report/readme/ROADMAP.rst @@ -0,0 +1 @@ +* support horizontal mode for xslx export diff --git a/mis_template_financial_report/readme/USAGE.rst b/mis_template_financial_report/readme/USAGE.rst new file mode 100644 index 00000000..d24a5bbb --- /dev/null +++ b/mis_template_financial_report/readme/USAGE.rst @@ -0,0 +1,3 @@ +Select one of the `Profit & Loss` or `Balance Sheet` templates in a new MIS report. + +For details, refer to the `MIS Builder documentation `_ diff --git a/mis_template_financial_report/readme/newsfragments/.gitkeep b/mis_template_financial_report/readme/newsfragments/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/mis_template_financial_report/static/description/icon.png b/mis_template_financial_report/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/mis_template_financial_report/static/description/icon.png differ diff --git a/mis_template_financial_report/static/description/index.html b/mis_template_financial_report/static/description/index.html new file mode 100644 index 00000000..904d3a37 --- /dev/null +++ b/mis_template_financial_report/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Dutch MIS Builder templates + + + +
+

Dutch MIS Builder templates

+ + +

Beta License: AGPL-3 OCA/account-financial-reporting Translate me on Weblate Try me on Runbot

+

This addon provides MIS builder templates to generate Dutch style Profit&Loss and Balance Sheet reports.

+

Table of contents

+ +
+

Usage

+

Select one of the Profit & Loss or Balance Sheet templates in a new MIS report.

+

For details, refer to the MIS Builder documentation

+
+
+

Known issues / Roadmap

+
    +
  • support horizontal mode for xslx export
  • +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Hunki Enterprises BV
  • +
+
+ +
+

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.

+

Current maintainer:

+

hbrunn

+

This module is part of the OCA/account-financial-reporting project on GitHub.

+

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

+
+
+
+ + diff --git a/mis_template_financial_report/static/src/css/mis_template_financial_report.css b/mis_template_financial_report/static/src/css/mis_template_financial_report.css new file mode 100644 index 00000000..158cfb01 --- /dev/null +++ b/mis_template_financial_report/static/src/css/mis_template_financial_report.css @@ -0,0 +1,7 @@ +.oe_mis_builder_content div.mis_builder_horizontal { + display: flex; + width: 100%; +} +.oe_mis_builder_content div.mis_builder_horizontal .table { + width: 50%; +} diff --git a/mis_template_financial_report/static/src/css/report.css b/mis_template_financial_report/static/src/css/report.css new file mode 100644 index 00000000..376d0ed2 --- /dev/null +++ b/mis_template_financial_report/static/src/css/report.css @@ -0,0 +1,11 @@ +div.mis_builder_horizontal { + display: table; + width: 100%; +} +div.mis_builder_horizontal > div { + display: table-row; +} +div.mis_builder_horizontal > div > div { + display: table-cell; + padding: 2px; +} diff --git a/mis_template_financial_report/static/src/xml/mis_template_financial_report.xml b/mis_template_financial_report/static/src/xml/mis_template_financial_report.xml new file mode 100644 index 00000000..31fb0f5c --- /dev/null +++ b/mis_template_financial_report/static/src/xml/mis_template_financial_report.xml @@ -0,0 +1,22 @@ + diff --git a/mis_template_financial_report/tests/__init__.py b/mis_template_financial_report/tests/__init__.py new file mode 100644 index 00000000..b7acc970 --- /dev/null +++ b/mis_template_financial_report/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mis_template_financial_report diff --git a/mis_template_financial_report/tests/test_mis_template_financial_report.py b/mis_template_financial_report/tests/test_mis_template_financial_report.py new file mode 100644 index 00000000..c6ab4892 --- /dev/null +++ b/mis_template_financial_report/tests/test_mis_template_financial_report.py @@ -0,0 +1,15 @@ +# Copyright 2020 Hunki Enterprises BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.mis_builder.tests.test_mis_report_instance import TestMisReportInstance + + +class TestMisTemplateFinancialReport(TestMisReportInstance): + def test_mis_template_financial_report(self): + instance = self.env["mis.report.instance"].create( + { + "name": "Balance Sheet", + "report_id": self.env.ref("mis_template_financial_report.report_bs").id, + } + ) + result_dict = instance.compute() + self.assertEqual(len(result_dict.get("horizontal_matrices", [])), 2) diff --git a/mis_template_financial_report/views/templates.xml b/mis_template_financial_report/views/templates.xml new file mode 100644 index 00000000..7e341591 --- /dev/null +++ b/mis_template_financial_report/views/templates.xml @@ -0,0 +1,58 @@ + + + + +