Skip to content

Commit 5076fab

Browse files
[MIG] bi_sql_editor: Migration to 17.0
1 parent c127fa0 commit 5076fab

File tree

8 files changed

+133
-160
lines changed

8 files changed

+133
-160
lines changed

bi_sql_editor/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ To use this module, you need to:
135135

136136
..
137137
138-
|image1|
138+
|usage-image1|
139139

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

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

144144
Bug Tracker
145145
===========

bi_sql_editor/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "BI SQL Editor",
77
"summary": "BI Views builder, based on Materialized or Normal SQL Views",
8-
"version": "16.0.1.0.5",
8+
"version": "17.0.1.0.0",
99
"license": "AGPL-3",
1010
"category": "Reporting",
1111
"author": "GRAP,Odoo Community Association (OCA)",

bi_sql_editor/hooks.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# Copyright 2015-2017 Onestein (<http://www.onestein.eu>)
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3-
from odoo import SUPERUSER_ID
4-
from odoo.api import Environment
53

64

7-
def uninstall_hook(cr, registry):
8-
env = Environment(cr, SUPERUSER_ID, {})
5+
def uninstall_hook(env):
96
recs = env["bi.sql.view"].search([])
107
for rec in recs:
118
rec.button_set_draft()

bi_sql_editor/models/bi_sql_view.py

+3-27
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ class BiSQLView(models.Model):
5959
is_materialized = fields.Boolean(
6060
string="Is Materialized View",
6161
default=True,
62-
readonly=True,
63-
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
6462
)
6563

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

7674
view_order = fields.Char(
7775
required=True,
78-
readonly=False,
79-
states={"ui_valid": [("readonly", True)]},
8076
default="pivot,graph,tree",
8177
help="Comma-separated text. Possible values:" ' "graph", "pivot" or "tree"',
8278
)
@@ -93,28 +89,20 @@ class BiSQLView(models.Model):
9389
domain_force = fields.Text(
9490
string="Extra Rule Definition",
9591
default="[]",
96-
readonly=True,
9792
help="Define here access restriction to data.\n"
9893
" Take care to use field name prefixed by 'x_'."
9994
" A global 'ir.rule' will be created."
10095
" A typical Multi Company rule is for exemple \n"
10196
" ['|', ('x_company_id','child_of', [user.company_id.id]),"
10297
"('x_company_id','=',False)].",
103-
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
10498
)
10599

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

108102
action_context = fields.Text(
109103
default="{}",
110-
readonly=True,
111104
help="Define here a context that will be used"
112105
" by default, when creating the action.",
113-
states={
114-
"draft": [("readonly", False)],
115-
"sql_valid": [("readonly", False)],
116-
"model_valid": [("readonly", False)],
117-
},
118106
)
119107

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

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

164-
group_ids = fields.Many2many(
165-
comodel_name="res.groups",
166-
readonly=True,
167-
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
168-
)
169-
170152
sequence = fields.Integer(string="sequence")
171153

172154
# Constrains Section
@@ -522,8 +504,7 @@ def _log_execute(self, req):
522504
def _drop_view(self):
523505
for sql_view in self:
524506
self._log_execute(
525-
"DROP %s VIEW IF EXISTS %s"
526-
% (sql_view.materialized_text, sql_view.view_name)
507+
f"DROP {sql_view.materialized_text} VIEW IF EXISTS {sql_view.view_name}"
527508
)
528509
sql_view.size = False
529510

@@ -552,12 +533,7 @@ def _create_index(self):
552533
lambda x: x.is_index is True
553534
):
554535
self._log_execute(
555-
"CREATE INDEX %(index_name)s ON %(view_name)s (%(field_name)s);"
556-
% {
557-
"index_name": sql_field.index_name,
558-
"view_name": sql_view.view_name,
559-
"field_name": sql_field.name,
560-
}
536+
f"CREATE INDEX {sql_field.index_name} ON {sql_view.view_name} ({sql_field.name});"
561537
)
562538

563539
def _create_model_and_fields(self):
@@ -639,7 +615,7 @@ def _check_execution(self):
639615
field_ids = []
640616
for column in columns:
641617
existing_field = self.bi_sql_view_field_ids.filtered(
642-
lambda x: x.name == column[1]
618+
lambda x: x.name == column[1] # noqa: B023
643619
)
644620
if existing_field:
645621
# Update existing field

bi_sql_editor/models/bi_sql_view_field.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,29 @@ class BiSQLViewField(models.Model):
7676
help="Check this box if you want to create"
7777
" an index on that field. This is recommended for searchable and"
7878
" groupable fields, to reduce duration",
79-
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
8079
)
8180

8281
is_group_by = fields.Boolean(
8382
string="Is Group by",
8483
help="Check this box if you want to create"
8584
" a 'group by' option in the search view",
86-
states={"ui_valid": [("readonly", True)]},
8785
)
8886

8987
index_name = fields.Char(compute="_compute_index_name")
9088

9189
graph_type = fields.Selection(
9290
selection=_GRAPH_TYPE_SELECTION,
93-
states={"ui_valid": [("readonly", True)]},
9491
)
9592

9693
tree_visibility = fields.Selection(
9794
selection=_TREE_VISIBILITY_SELECTION,
9895
default="available",
9996
required=True,
100-
states={"ui_valid": [("readonly", True)]},
10197
)
10298

10399
field_description = fields.Char(
104100
help="This will be used as the name of the Odoo field, displayed for users",
105101
required=True,
106-
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
107102
)
108103

109104
ttype = fields.Selection(
@@ -113,7 +108,6 @@ class BiSQLViewField(models.Model):
113108
" Odoo field that will be created. Keep empty if you don't want to"
114109
" create a new field. If empty, this field will not be displayed"
115110
" neither available for search or group by function",
116-
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
117111
)
118112

119113
selection = fields.Text(
@@ -123,28 +117,24 @@ class BiSQLViewField(models.Model):
123117
" List of options, specified as a Python expression defining a list of"
124118
" (key, label) pairs. For example:"
125119
" [('blue','Blue'), ('yellow','Yellow')]",
126-
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
127120
)
128121

129122
many2one_model_id = fields.Many2one(
130123
comodel_name="ir.model",
131124
string="Model",
132125
help="For 'Many2one' Odoo field.\n" " Comodel of the field.",
133-
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
134126
)
135127

136128
group_operator = fields.Selection(
137129
selection=_GROUP_OPERATOR_SELECTION,
138130
help="By default, Odoo will sum the values when grouping. If you wish "
139131
"to alter the behaviour, choose an alternate Group Operator",
140-
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
141132
)
142133

143134
field_context = fields.Char(
144135
default="{}",
145136
help="Context value that will be inserted for this field in all the views."
146137
" Important note : please write a context with single quote.",
147-
states={"ui_valid": [("readonly", True)]},
148138
)
149139

150140
# Constrains Section
@@ -255,7 +245,7 @@ def _prepare_tree_field(self):
255245
return ""
256246
visibility_text = ""
257247
if self.tree_visibility == "invisible":
258-
visibility_text = 'invisible="1"'
248+
visibility_text = 'column_invisible="1"'
259249
elif self.tree_visibility == "optional_hide":
260250
visibility_text = 'optional="hide"'
261251
elif self.tree_visibility == "optional_show":

bi_sql_editor/readme/USAGE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ To use this module, you need to:
33
1. Go to 'Dashboards \> SQL Reports'
44
2. Select the desired report
55

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

0 commit comments

Comments
 (0)