From b2e4edfddad33227adb72752a2268bc90403dd4a Mon Sep 17 00:00:00 2001 From: Wesley Oliveira Date: Fri, 14 Mar 2025 17:40:02 -0300 Subject: [PATCH] [ADD] mis_builder_bi_sql_editor: add new module --- mis_builder_bi_sql_editor/README.rst | 132 +++++ mis_builder_bi_sql_editor/__init__.py | 1 + mis_builder_bi_sql_editor/__manifest__.py | 25 + .../data/mis_builder_bi_sql_line_cron.xml | 18 + mis_builder_bi_sql_editor/models/__init__.py | 4 + .../models/bi_sql_view.py | 111 ++++ .../models/mis_builder_bi_sql_line.py | 49 ++ .../models/mis_report.py | 28 ++ .../models/mis_report_instance.py | 60 +++ .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 1 + mis_builder_bi_sql_editor/readme/USAGE.rst | 36 ++ .../security/ir.model.access.csv | 3 + .../static/description/icon.png | Bin 0 -> 4770 bytes .../static/description/index.html | 473 ++++++++++++++++++ .../views/bi_sql_view.xml | 33 ++ .../views/mis_builder_bi_sql_line.xml | 42 ++ .../views/mis_report.xml | 21 + .../views/mis_report_instance.xml | 26 + oca_dependencies.txt | 3 +- .../odoo/addons/mis_builder_bi_sql_editor | 1 + setup/mis_builder_bi_sql_editor/setup.py | 6 + 22 files changed, 1076 insertions(+), 1 deletion(-) create mode 100644 mis_builder_bi_sql_editor/README.rst create mode 100644 mis_builder_bi_sql_editor/__init__.py create mode 100644 mis_builder_bi_sql_editor/__manifest__.py create mode 100644 mis_builder_bi_sql_editor/data/mis_builder_bi_sql_line_cron.xml create mode 100644 mis_builder_bi_sql_editor/models/__init__.py create mode 100644 mis_builder_bi_sql_editor/models/bi_sql_view.py create mode 100644 mis_builder_bi_sql_editor/models/mis_builder_bi_sql_line.py create mode 100644 mis_builder_bi_sql_editor/models/mis_report.py create mode 100644 mis_builder_bi_sql_editor/models/mis_report_instance.py create mode 100644 mis_builder_bi_sql_editor/readme/CONTRIBUTORS.rst create mode 100644 mis_builder_bi_sql_editor/readme/DESCRIPTION.rst create mode 100644 mis_builder_bi_sql_editor/readme/USAGE.rst create mode 100644 mis_builder_bi_sql_editor/security/ir.model.access.csv create mode 100644 mis_builder_bi_sql_editor/static/description/icon.png create mode 100644 mis_builder_bi_sql_editor/static/description/index.html create mode 100644 mis_builder_bi_sql_editor/views/bi_sql_view.xml create mode 100644 mis_builder_bi_sql_editor/views/mis_builder_bi_sql_line.xml create mode 100644 mis_builder_bi_sql_editor/views/mis_report.xml create mode 100644 mis_builder_bi_sql_editor/views/mis_report_instance.xml create mode 120000 setup/mis_builder_bi_sql_editor/odoo/addons/mis_builder_bi_sql_editor create mode 100644 setup/mis_builder_bi_sql_editor/setup.py diff --git a/mis_builder_bi_sql_editor/README.rst b/mis_builder_bi_sql_editor/README.rst new file mode 100644 index 0000000..5582fb1 --- /dev/null +++ b/mis_builder_bi_sql_editor/README.rst @@ -0,0 +1,132 @@ +========================= +MIS Builder BI SQL Editor +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:41e107b1dbd1b78c2a4318f783b10b9e30119cb8d9ed1d515c4e2c1673ea8220 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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/14.0/mis_builder_bi_sql_editor + :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-14-0/mis-builder-contrib-14-0-mis_builder_bi_sql_editor + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module make the BI SQL Editor query models compatible with MIS Builder. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +Create a query with SQL BI Editor: + +- Use the BI SQL Editor to create your query. +- Make sure your query includes the required fields: `x_credit`, `x_debit`, `x_account_id`, `x_date` and `x_company_id`. +- Optionally, you can include the `x_analytic_account_id` field for analytical account support. + +Field Requirements: + +- `x_credit`: Must have type float. +- `x_debit`: Must have type float. +- `x_date`: Must have the date type. +- `x_account_id`: Must have the type many2one and be associated with the `account.account` model. +- `x_company_id`: Must have the type many2one and be associated with the `res.company` model. +- `x_analytic_account_id` (optional): Must have the type many2one and be associated with the `account.analytic.account` model. + +Activate MIS Builder in the query model: + +- Once your query meets the above requirements, click the “Activate MIS Builder” button. +- This will signal that the query should be used in the "Refresh MIS Builder BI SQL Lines" cron. +- Refreshing materialized view will also create new lines in the model (if there are new lines). + +Remove MIS Builder in the query model: + +- If you no longer need MIS Builder compatibility, click the "Remove MIS Builder" button. +- This will delete the rows and columns related to your BI SQL model. + +Create MIS Builder report: + +- When creating a MIS Builder Report, select "BI SQL MIS Builder Line" as the source. +- Afterwards, select the BI SQL View you want to use (The view must have MIS Builder activated). +- When creating kpis for this report, you can use MIS expressions to filter the fields in your query. +- To do this, it is necessary to use the name of the BI SQL View. +- Example: `bal[][('x_bi_sql_view_mis.x_name', '=', 'test')]`. +- This will filter out the lines in your query that have the `x_name` field with "test" as the value. + +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 +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Marcel Savegnago + * Wesley Oliveira + +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-WesleyOliveira98| image:: https://github.com/WesleyOliveira98.png?size=40px + :target: https://github.com/WesleyOliveira98 + :alt: WesleyOliveira98 + +Current `maintainer `__: + +|maintainer-WesleyOliveira98| + +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_bi_sql_editor/__init__.py b/mis_builder_bi_sql_editor/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/mis_builder_bi_sql_editor/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mis_builder_bi_sql_editor/__manifest__.py b/mis_builder_bi_sql_editor/__manifest__.py new file mode 100644 index 0000000..d3cd7d2 --- /dev/null +++ b/mis_builder_bi_sql_editor/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2025 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "MIS Builder BI SQL Editor", + "summary": """ + Integrate MIS Builder to BI SQL Editor""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Escodoo," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/mis-builder-contrib", + "depends": ["mis_builder", "bi_sql_editor"], + "data": [ + "views/bi_sql_view.xml", + "views/mis_builder_bi_sql_line.xml", + "views/mis_report_instance.xml", + "views/mis_report.xml", + "security/ir.model.access.csv", + "data/mis_builder_bi_sql_line_cron.xml", + ], + "installable": True, + "application": True, + "development_status": "Alpha", + "maintainers": ["WesleyOliveira98"], +} diff --git a/mis_builder_bi_sql_editor/data/mis_builder_bi_sql_line_cron.xml b/mis_builder_bi_sql_editor/data/mis_builder_bi_sql_line_cron.xml new file mode 100644 index 0000000..40d68af --- /dev/null +++ b/mis_builder_bi_sql_editor/data/mis_builder_bi_sql_line_cron.xml @@ -0,0 +1,18 @@ + + + + + + Refresh MIS Builder BI SQL Lines + + code + model._create_mis_builder_bi_sql_lines() + + 1 + days + -1 + + + + diff --git a/mis_builder_bi_sql_editor/models/__init__.py b/mis_builder_bi_sql_editor/models/__init__.py new file mode 100644 index 0000000..c47ddd7 --- /dev/null +++ b/mis_builder_bi_sql_editor/models/__init__.py @@ -0,0 +1,4 @@ +from . import bi_sql_view +from . import mis_builder_bi_sql_line +from . import mis_report_instance +from . import mis_report diff --git a/mis_builder_bi_sql_editor/models/bi_sql_view.py b/mis_builder_bi_sql_editor/models/bi_sql_view.py new file mode 100644 index 0000000..75a48ad --- /dev/null +++ b/mis_builder_bi_sql_editor/models/bi_sql_view.py @@ -0,0 +1,111 @@ +# Copyright 2025 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class BiSQLView(models.Model): + + _inherit = "bi.sql.view" + + mis_builder_compatible = fields.Boolean( + compute="_compute_mis_builder_compatible", + default=False, + ) + mis_builder_activated = fields.Boolean(default=False) + + @api.depends() + def _compute_mis_builder_compatible(self): + compatible = True + model_sql_fields = self.bi_sql_view_field_ids + credit_field = model_sql_fields.filtered( + lambda x: x.name == "x_credit" and x.ttype == "float" + ) + debit_field = model_sql_fields.filtered( + lambda x: x.name == "x_debit" and x.ttype == "float" + ) + account_field = model_sql_fields.filtered( + lambda x: x.name == "x_account_id" and x.ttype == "many2one" + ) + date_field = model_sql_fields.filtered( + lambda x: x.name == "x_date" and x.ttype == "date" + ) + company_field = model_sql_fields.filtered( + lambda x: x.name == "x_company_id" and x.ttype == "many2one" + ) + analytic_account_field = model_sql_fields.filtered( + lambda x: x.name == "x_analytic_account_id" and x.ttype == "many2one" + ) + + if ( + not credit_field + or not debit_field + or not account_field + or account_field.many2one_model_id.model != "account.account" + or not date_field + or not company_field + or company_field.many2one_model_id.model != "res.company" + or ( + analytic_account_field + and analytic_account_field.many2one_model_id.model + != "account.analytic.account" + ) + ): + compatible = False + + self.mis_builder_compatible = compatible + + def activate_mis_builder(self): + if self.mis_builder_compatible: + model_id = ( + self.env["ir.model"] + .search([("model", "=", "mis.builder.bi.sql.line")]) + .id + ) + self.env["ir.model.fields"].create( + { + "name": self.view_name, + "model_id": model_id, + "state": "manual", + "ttype": "many2one", + "relation": self.model_name, + } + ) + self.mis_builder_activated = True + + def remove_mis_builder(self): + if self.mis_builder_compatible and self.mis_builder_activated: + self.env["mis.builder.bi.sql.line"].search( + [("bi_sql_model", "=", self.model_id.id)] + ).unlink() + + model_id = ( + self.env["ir.model"] + .search([("model", "=", "mis.builder.bi.sql.line")]) + .id + ) + self.env["ir.model.fields"].search( + [ + ("name", "=", self.view_name), + ("model_id", "=", model_id), + ] + ).unlink() + + self.mis_builder_activated = False + + def button_set_draft(self): + if self.mis_builder_activated: + self.remove_mis_builder() + return super().button_set_draft() + + def button_refresh_materialized_view(self): + super().button_refresh_materialized_view() + if self.mis_builder_activated: + model = self.env["mis.builder.bi.sql.line"] + model._create_mis_builder_bi_sql_lines() + + def copy(self, default=None): + self.ensure_one() + default = dict(default or {}) + default["mis_builder_activated"] = False + return super().copy(default) diff --git a/mis_builder_bi_sql_editor/models/mis_builder_bi_sql_line.py b/mis_builder_bi_sql_editor/models/mis_builder_bi_sql_line.py new file mode 100644 index 0000000..b3cf42d --- /dev/null +++ b/mis_builder_bi_sql_editor/models/mis_builder_bi_sql_line.py @@ -0,0 +1,49 @@ +# Copyright 2025 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MisBuilderBiSqlLine(models.Model): + _name = "mis.builder.bi.sql.line" + _description = "MIS Builder BI SQL Line" + + credit = fields.Float() + debit = fields.Float() + account_id = fields.Many2one(comodel_name="account.account") + date = fields.Date() + company_id = fields.Many2one(comodel_name="res.company") + analytic_account_id = fields.Many2one(comodel_name="account.analytic.account") + bi_sql_model = fields.Many2one(comodel_name="ir.model") + res_id = fields.Integer() + + def _create_mis_builder_bi_sql_lines(self): + sql_view_ids = self.env["bi.sql.view"].search( + [ + ("mis_builder_compatible", "=", True), + ("mis_builder_activated", "=", True), + ] + ) + for sql_view in sql_view_ids: + res = self.env[sql_view.model_id.model].search([]) + for line in res: + mis_sql_line = self.env["mis.builder.bi.sql.line"].search( + [ + ("bi_sql_model", "=", sql_view.model_id.id), + ("res_id", "=", line.id), + ], + limit=1, + ) + if not mis_sql_line: + vals = { + "credit": line.x_credit, + "debit": line.x_debit, + "account_id": line.x_account_id.id, + "date": line.x_date, + "company_id": line.x_company_id.id, + "analytic_account_id": line.x_analytic_account_id.id or False, + "bi_sql_model": sql_view.model_id.id, + "res_id": line.id, + } + vals[sql_view.view_name] = line.id + self.create(vals) diff --git a/mis_builder_bi_sql_editor/models/mis_report.py b/mis_builder_bi_sql_editor/models/mis_report.py new file mode 100644 index 0000000..54974f8 --- /dev/null +++ b/mis_builder_bi_sql_editor/models/mis_report.py @@ -0,0 +1,28 @@ +# Copyright 2025 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class MisReport(models.Model): + + _inherit = "mis.report" + + bi_sql_view = fields.Many2one( + string="BI SQL View", + comodel_name="bi.sql.view", + domain=[("mis_builder_activated", "=", True)], + ) + bi_sql_view_required = fields.Boolean( + default=False, compute="_compute_bi_sql_view_required" + ) + + @api.depends("move_lines_source") + def _compute_bi_sql_view_required(self): + for record in self: + model_id = ( + self.env["ir.model"] + .search([("model", "=", "mis.builder.bi.sql.line")]) + .id + ) + record.bi_sql_view_required = record.move_lines_source.id == model_id diff --git a/mis_builder_bi_sql_editor/models/mis_report_instance.py b/mis_builder_bi_sql_editor/models/mis_report_instance.py new file mode 100644 index 0000000..a083ae0 --- /dev/null +++ b/mis_builder_bi_sql_editor/models/mis_report_instance.py @@ -0,0 +1,60 @@ +# Copyright 2025 - TODAY, Wesley Oliveira +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class MisReportInstancePeriod(models.Model): + + _inherit = "mis.report.instance.period" + + bi_sql_view = fields.Many2one( + string="BI SQL View", + comodel_name="bi.sql.view", + domain=[("mis_builder_activated", "=", True)], + ) + bi_sql_view_required = fields.Boolean( + default=False, compute="_compute_bi_sql_view_required" + ) + + @api.depends("source", "source_aml_model_id") + def _compute_bi_sql_view_required(self): + for record in self: + if record.source == "actuals_alt": + model_id = ( + self.env["ir.model"] + .search([("model", "=", "mis.builder.bi.sql.line")]) + .id + ) + record.bi_sql_view_required = record.source_aml_model_id.id == model_id + else: + record.bi_sql_view_required = False + + def _get_additional_move_line_filter(self): + context = self.env.context + if self.bi_sql_view: + context["mis_report_filters"]["bi_sql_model"] = { + "value": self.bi_sql_view.model_id.id, + "operator": "=", + } + return super()._get_additional_move_line_filter() + + +class MisReportInstance(models.Model): + + _inherit = "mis.report.instance" + + bi_sql_view = fields.Many2one( + string="BI SQL View", + comodel_name="bi.sql.view", + related="report_id.bi_sql_view", + ) + + def _context_with_filters(self): + context = super()._context_with_filters() + if self.bi_sql_view: + context["mis_report_filters"]["bi_sql_model"] = { + "value": self.bi_sql_view.model_id.id, + "operator": "=", + } + return context diff --git a/mis_builder_bi_sql_editor/readme/CONTRIBUTORS.rst b/mis_builder_bi_sql_editor/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..bc15bdc --- /dev/null +++ b/mis_builder_bi_sql_editor/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Escodoo `_: + + * Marcel Savegnago + * Wesley Oliveira diff --git a/mis_builder_bi_sql_editor/readme/DESCRIPTION.rst b/mis_builder_bi_sql_editor/readme/DESCRIPTION.rst new file mode 100644 index 0000000..c004166 --- /dev/null +++ b/mis_builder_bi_sql_editor/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module make the BI SQL Editor query models compatible with MIS Builder. diff --git a/mis_builder_bi_sql_editor/readme/USAGE.rst b/mis_builder_bi_sql_editor/readme/USAGE.rst new file mode 100644 index 0000000..25ba77c --- /dev/null +++ b/mis_builder_bi_sql_editor/readme/USAGE.rst @@ -0,0 +1,36 @@ +To use this module, you need to: + +Create a query with SQL BI Editor: + +- Use the BI SQL Editor to create your query. +- Make sure your query includes the required fields: `x_credit`, `x_debit`, `x_account_id`, `x_date` and `x_company_id`. +- Optionally, you can include the `x_analytic_account_id` field for analytical account support. + +Field Requirements: + +- `x_credit`: Must have type float. +- `x_debit`: Must have type float. +- `x_date`: Must have the date type. +- `x_account_id`: Must have the type many2one and be associated with the `account.account` model. +- `x_company_id`: Must have the type many2one and be associated with the `res.company` model. +- `x_analytic_account_id` (optional): Must have the type many2one and be associated with the `account.analytic.account` model. + +Activate MIS Builder in the query model: + +- Once your query meets the above requirements, click the “Activate MIS Builder” button. +- This will signal that the query should be used in the "Refresh MIS Builder BI SQL Lines" cron. +- Refreshing materialized view will also create new lines in the model (if there are new lines). + +Remove MIS Builder in the query model: + +- If you no longer need MIS Builder compatibility, click the "Remove MIS Builder" button. +- This will delete the rows and columns related to your BI SQL model. + +Create MIS Builder report: + +- When creating a MIS Builder Report, select "BI SQL MIS Builder Line" as the source. +- Afterwards, select the BI SQL View you want to use (The view must have MIS Builder activated). +- When creating kpis for this report, you can use MIS expressions to filter the fields in your query. +- To do this, it is necessary to use the name of the BI SQL View. +- Example: `bal[][('x_bi_sql_view_mis.x_name', '=', 'test')]`. +- This will filter out the lines in your query that have the `x_name` field with "test" as the value. diff --git a/mis_builder_bi_sql_editor/security/ir.model.access.csv b/mis_builder_bi_sql_editor/security/ir.model.access.csv new file mode 100644 index 0000000..1a41153 --- /dev/null +++ b/mis_builder_bi_sql_editor/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_mis_builder_bi_sql_line,access_mis_builder_bi_sql_line,model_mis_builder_bi_sql_line,base.group_user,1,0,0,0 +manage_mis_builder_bi_sql_line,manage_mis_builder_bi_sql_line,model_mis_builder_bi_sql_line,account.group_account_manager,1,1,1,1 diff --git a/mis_builder_bi_sql_editor/static/description/icon.png b/mis_builder_bi_sql_editor/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1afa781fabb8088818f3940ef56711e6281bd31e GIT binary patch literal 4770 zcmZu#byO7G(*^`-1OX}O5~N$YVTlD{Q6!g;TpA>nW(g_D1?dGOr9)!r66st*Kysy} zOW?!v{{H;#IdkXS^PFeS+_^P#Kk5S2hzV#3FfcHP0qV+n4;ubY@E$+((wJ^*59+a{ zrke7DerQ)ptw9e8-&Osc2L=Y!(|>|#n>+cBhwBN@R>57xXCN0N`MDf|iGlHyAE2xN z@>$r=_D!Lj$sUmVR<_*kCEiwzCngeu*A<0HcERq`DZ`RKXl)~%+&7rT=CPHY1@O!| z8nzbVNREBiOD*aqQov&cN@-I0$n+7_$GVSx^mOn;a#Q9_j&eludW`g^uB2DL>Xhs<9C6?>g9pDwANnsWlvHf z6bX3Pao|ZXZ};LyiA{{~-^+f5-#yKjeY(kMkepf%6~bpRpV3 zrpEV*kBVW#USX*?TrbOQ!!cxn|EP6Q$zBp^;>`Z(f6X`vQG>hN6^zO&tFekaa^<#R zN|;o&kxCqVX6;R=NFFsuJ^qM^9%t57o?VakyY3^z(BS~elPkj+WR2G71TV8cuceHtq~$OJ$7G_upsGaJd)v zI~yb|!5TPbdAnaJco@%G8cnH^`Z2lgYU{`4huHx^Pu}kkxTvdqP#nLa_in z;`A$}9N+w+L!z0j&>Kp^=hTFVek>wiZK9SRrq>7m z$seeRc_*+aFD(5CE|{gO@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fI#6@to=POIv4-*Vg#vji`h^fon;AYB%BvD8zvO6m55YN44=fUm*L&&%@J z1y4wFZ$T+joDqWBgo|$CAOfB=C4*Y#&kfCB2iUu07HciK#mZRW9125c7(q4t@6ov| zVfOBM{eq2JF*xtbtzQB-a6*JTn`aU4D1^YRtDgEQOM4=T(u+15Ysg6#^WiR|iDTXx ziPGnhpwOsYiXH$o5G zj8QgPudUP#KFZ<_m5sCRFY_s(Fzg{Rc-vpZQC9bR7`rPtkJGBaepzDGEJRdG*UQ#v zjX9fcw2Xyec3aR%x;q8Su_;eu>p50LzgHbOTYdyO@8P^Y0+k}ebf`?^ilbX#3PMf~ z1vk#DTLgEucf!-k>{ReH9%E^&Y2u&`4m>7Lh>#>6<|vm8hGgf0jP@1EJY#j=6OgD7 zR?4!D!UQq(io#Ll7nFudL8us1X}&)RW{`_g6G zg*2im4f!I=>;QVckz>G5$J<2$HVfUd3jf?91Hny44NOHuyY~ihHKVi1aUa|QE2%UW zHVxIkvUP_wQyS`h?Q~}b#ls%iX9{yhG=YukSu`I^I)_EO1CECKnNEN&(#1T&V~S{XZy`IspIx literal 0 HcmV?d00001 diff --git a/mis_builder_bi_sql_editor/static/description/index.html b/mis_builder_bi_sql_editor/static/description/index.html new file mode 100644 index 0000000..68fdc77 --- /dev/null +++ b/mis_builder_bi_sql_editor/static/description/index.html @@ -0,0 +1,473 @@ + + + + + + +MIS Builder BI SQL Editor + + + +

+

MIS Builder BI SQL Editor

+ + +

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

+

This module make the BI SQL Editor query models compatible with MIS Builder.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+

Create a query with SQL BI Editor:

+
    +
  • Use the BI SQL Editor to create your query.
  • +
  • Make sure your query includes the required fields: x_credit, x_debit, x_account_id, x_date and x_company_id.
  • +
  • Optionally, you can include the x_analytic_account_id field for analytical account support.
  • +
+

Field Requirements:

+
    +
  • x_credit: Must have type float.
  • +
  • x_debit: Must have type float.
  • +
  • x_date: Must have the date type.
  • +
  • x_account_id: Must have the type many2one and be associated with the account.account model.
  • +
  • x_company_id: Must have the type many2one and be associated with the res.company model.
  • +
  • x_analytic_account_id (optional): Must have the type many2one and be associated with the account.analytic.account model.
  • +
+

Activate MIS Builder in the query model:

+
    +
  • Once your query meets the above requirements, click the “Activate MIS Builder” button.
  • +
  • This will signal that the query should be used in the “Refresh MIS Builder BI SQL Lines” cron.
  • +
  • Refreshing materialized view will also create new lines in the model (if there are new lines).
  • +
+

Remove MIS Builder in the query model:

+
    +
  • If you no longer need MIS Builder compatibility, click the “Remove MIS Builder” button.
  • +
  • This will delete the rows and columns related to your BI SQL model.
  • +
+

Create MIS Builder report:

+
    +
  • When creating a MIS Builder Report, select “BI SQL MIS Builder Line” as the source.
  • +
  • Afterwards, select the BI SQL View you want to use (The view must have MIS Builder activated).
  • +
  • When creating kpis for this report, you can use MIS expressions to filter the fields in your query.
  • +
  • To do this, it is necessary to use the name of the BI SQL View.
  • +
  • Example: bal[][(‘x_bi_sql_view_mis.x_name’, ‘=’, ‘test’)].
  • +
  • This will filter out the lines in your query that have the x_name field with “test” as the value.
  • +
+
+
+

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

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

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:

+

WesleyOliveira98

+

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_bi_sql_editor/views/bi_sql_view.xml b/mis_builder_bi_sql_editor/views/bi_sql_view.xml new file mode 100644 index 0000000..5db7e78 --- /dev/null +++ b/mis_builder_bi_sql_editor/views/bi_sql_view.xml @@ -0,0 +1,33 @@ + + + + + + bi.sql.view.form (in mis_builder_bi_sql_editor) + bi.sql.view + + +
+
+ + + + + +
+ +
diff --git a/mis_builder_bi_sql_editor/views/mis_builder_bi_sql_line.xml b/mis_builder_bi_sql_editor/views/mis_builder_bi_sql_line.xml new file mode 100644 index 0000000..018775f --- /dev/null +++ b/mis_builder_bi_sql_editor/views/mis_builder_bi_sql_line.xml @@ -0,0 +1,42 @@ + + + + + + mis.builder.bi.sql.line.form + mis.builder.bi.sql.line + +
+ + + + + + + + + + + + +
+
+
+ + + mis.builder.bi.sql.line.tree + mis.builder.bi.sql.line + + + + + + + + + + + + +
diff --git a/mis_builder_bi_sql_editor/views/mis_report.xml b/mis_builder_bi_sql_editor/views/mis_report.xml new file mode 100644 index 0000000..3e2e741 --- /dev/null +++ b/mis_builder_bi_sql_editor/views/mis_report.xml @@ -0,0 +1,21 @@ + + + + + + mis.report.view.form (in mis_builder_bi_sql_editor) + mis.report + + + + + + + + + + diff --git a/mis_builder_bi_sql_editor/views/mis_report_instance.xml b/mis_builder_bi_sql_editor/views/mis_report_instance.xml new file mode 100644 index 0000000..8d62d83 --- /dev/null +++ b/mis_builder_bi_sql_editor/views/mis_report_instance.xml @@ -0,0 +1,26 @@ + + + + + + mis.report.instance.period.form (in mis_builder_bi_sql_editor) + mis.report.instance.period + + + + + + + + + + diff --git a/oca_dependencies.txt b/oca_dependencies.txt index ca3c726..14e7422 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1 +1,2 @@ -# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt +mis_builder +reporting-engine diff --git a/setup/mis_builder_bi_sql_editor/odoo/addons/mis_builder_bi_sql_editor b/setup/mis_builder_bi_sql_editor/odoo/addons/mis_builder_bi_sql_editor new file mode 120000 index 0000000..3585e67 --- /dev/null +++ b/setup/mis_builder_bi_sql_editor/odoo/addons/mis_builder_bi_sql_editor @@ -0,0 +1 @@ +../../../../mis_builder_bi_sql_editor \ No newline at end of file diff --git a/setup/mis_builder_bi_sql_editor/setup.py b/setup/mis_builder_bi_sql_editor/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/mis_builder_bi_sql_editor/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)