Skip to content

Commit

Permalink
[MIG] bi_sql_editor: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenminhchien committed Dec 20, 2023
1 parent c1fc6dc commit d2a5bf5
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 151 deletions.
4 changes: 2 additions & 2 deletions bi_sql_editor/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ To use this module, you need to:

..
|image1|
|usage-image1|

- You can switch to 'Graph' or 'tree' views as any report.

.. |image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/17.0/bi_sql_editor/static/description/05_reporting_pivot.png
.. |usage-image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/17.0/bi_sql_editor/static/description/05_reporting_pivot.png

Bug Tracker
===========
Expand Down
2 changes: 1 addition & 1 deletion bi_sql_editor/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "BI SQL Editor",
"summary": "BI Views builder, based on Materialized or Normal SQL Views",
"version": "16.0.1.0.5",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"category": "Reporting",
"author": "GRAP,Odoo Community Association (OCA)",
Expand Down
5 changes: 1 addition & 4 deletions bi_sql_editor/hooks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Copyright 2015-2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import SUPERUSER_ID
from odoo.api import Environment


def uninstall_hook(cr, registry):
env = Environment(cr, SUPERUSER_ID, {})
def uninstall_hook(env):
recs = env["bi.sql.view"].search([])

Check warning on line 6 in bi_sql_editor/hooks.py

View check run for this annotation

Codecov / codecov/patch

bi_sql_editor/hooks.py#L6

Added line #L6 was not covered by tests
for rec in recs:
rec.button_set_draft()

Check warning on line 8 in bi_sql_editor/hooks.py

View check run for this annotation

Codecov / codecov/patch

bi_sql_editor/hooks.py#L8

Added line #L8 was not covered by tests
30 changes: 3 additions & 27 deletions bi_sql_editor/models/bi_sql_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class BiSQLView(models.Model):
is_materialized = fields.Boolean(
string="Is Materialized View",
default=True,
readonly=True,
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
)

materialized_text = fields.Char(compute="_compute_materialized_text", store=True)
Expand All @@ -75,8 +73,6 @@ class BiSQLView(models.Model):

view_order = fields.Char(
required=True,
readonly=False,
states={"ui_valid": [("readonly", True)]},
default="pivot,graph,tree",
help="Comma-separated text. Possible values:" ' "graph", "pivot" or "tree"',
)
Expand All @@ -93,28 +89,20 @@ class BiSQLView(models.Model):
domain_force = fields.Text(
string="Extra Rule Definition",
default="[]",
readonly=True,
help="Define here access restriction to data.\n"
" Take care to use field name prefixed by 'x_'."
" A global 'ir.rule' will be created."
" A typical Multi Company rule is for exemple \n"
" ['|', ('x_company_id','child_of', [user.company_id.id]),"
"('x_company_id','=',False)].",
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
)

computed_action_context = fields.Text(compute="_compute_computed_action_context")

action_context = fields.Text(
default="{}",
readonly=True,
help="Define here a context that will be used"
" by default, when creating the action.",
states={
"draft": [("readonly", False)],
"sql_valid": [("readonly", False)],
"model_valid": [("readonly", False)],
},
)

bi_sql_view_field_ids = fields.One2many(
Expand Down Expand Up @@ -161,12 +149,6 @@ class BiSQLView(models.Model):

rule_id = fields.Many2one(string="Odoo Rule", comodel_name="ir.rule", readonly=True)

group_ids = fields.Many2many(
comodel_name="res.groups",
readonly=True,
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
)

sequence = fields.Integer(string="sequence")

option_context_field = fields.Boolean(
Expand Down Expand Up @@ -516,8 +498,7 @@ def _log_execute(self, req):
def _drop_view(self):
for sql_view in self:
self._log_execute(
"DROP %s VIEW IF EXISTS %s"
% (sql_view.materialized_text, sql_view.view_name)
f"DROP {sql_view.materialized_text} VIEW IF EXISTS {sql_view.view_name}"
)
sql_view.size = False

Expand Down Expand Up @@ -546,12 +527,7 @@ def _create_index(self):
lambda x: x.is_index is True
):
self._log_execute(
"CREATE INDEX %(index_name)s ON %(view_name)s (%(field_name)s);"
% {
"index_name": sql_field.index_name,
"view_name": sql_view.view_name,
"field_name": sql_field.name,
}
f"CREATE INDEX {sql_field.index_name} ON {sql_view.view_name} ({sql_field.name});"
)

def _create_model_and_fields(self):
Expand Down Expand Up @@ -633,7 +609,7 @@ def _check_execution(self):
field_ids = []
for column in columns:
existing_field = self.bi_sql_view_field_ids.filtered(
lambda x: x.name == column[1]
lambda x: x.name == column[1] # noqa: B023
)
if existing_field:
# Update existing field
Expand Down
2 changes: 1 addition & 1 deletion bi_sql_editor/models/bi_sql_view_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _prepare_tree_field(self):
return ""
visibility_text = ""
if self.tree_visibility == "invisible":
visibility_text = 'invisible="1"'
visibility_text = 'column_invisible="1"'
elif self.tree_visibility == "optional_hide":
visibility_text = 'option="hide"'
elif self.tree_visibility == "optional_show":
Expand Down
2 changes: 1 addition & 1 deletion bi_sql_editor/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ To use this module, you need to:
1. Go to 'Dashboards \> SQL Reports'
2. Select the desired report

> ![](../static/description/05_reporting_pivot.png)
> ![usage-image1](../static/description/05_reporting_pivot.png)
- You can switch to 'Graph' or 'tree' views as any report.
Loading

0 comments on commit d2a5bf5

Please sign in to comment.