Skip to content

Commit 088160d

Browse files
committed
[MIG] bi_sql_editor: Migration to 19.0
1 parent 7bdc452 commit 088160d

8 files changed

Lines changed: 90 additions & 59 deletions

File tree

bi_sql_editor/README.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ BI SQL Editor
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
24-
:target: https://github.com/OCA/reporting-engine/tree/18.0/bi_sql_editor
24+
:target: https://github.com/OCA/reporting-engine/tree/19.0/bi_sql_editor
2525
:alt: OCA/reporting-engine
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-bi_sql_editor
27+
:target: https://translation.odoo-community.org/projects/reporting-engine-19-0/reporting-engine-19-0-bi_sql_editor
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -130,10 +130,10 @@ to make reporting depending on the current companies of the user.
130130
- Finally, click on 'Create UI', to create new menu, action, graph view
131131
and search view.
132132

133-
.. |image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/01_sql_request.png
134-
.. |image2| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/02_security_access.png
135-
.. |image3| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/03_field_mapping.png
136-
.. |image4| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/04_materialized_view_setting.png
133+
.. |image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/19.0/bi_sql_editor/static/description/01_sql_request.png
134+
.. |image2| image:: https://raw.githubusercontent.com/OCA/reporting-engine/19.0/bi_sql_editor/static/description/02_security_access.png
135+
.. |image3| image:: https://raw.githubusercontent.com/OCA/reporting-engine/19.0/bi_sql_editor/static/description/03_field_mapping.png
136+
.. |image4| image:: https://raw.githubusercontent.com/OCA/reporting-engine/19.0/bi_sql_editor/static/description/04_materialized_view_setting.png
137137

138138
Usage
139139
=====
@@ -149,15 +149,15 @@ To use this module, you need to:
149149

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

152-
.. |usage-image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/05_reporting_pivot.png
152+
.. |usage-image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/19.0/bi_sql_editor/static/description/05_reporting_pivot.png
153153

154154
Bug Tracker
155155
===========
156156

157157
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
158158
In case of trouble, please check there if your issue has already been reported.
159159
If you spotted it first, help us to smash it by providing a detailed and welcomed
160-
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20bi_sql_editor%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
160+
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20bi_sql_editor%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
161161

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

@@ -222,6 +222,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
222222

223223
|maintainer-legalsylvain|
224224

225-
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/18.0/bi_sql_editor>`_ project on GitHub.
225+
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/19.0/bi_sql_editor>`_ project on GitHub.
226226

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

bi_sql_editor/__manifest__.py

Lines changed: 1 addition & 1 deletion
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": "18.0.1.0.4",
8+
"version": "19.0.1.0.0",
99
"license": "AGPL-3",
1010
"category": "Reporting",
1111
"author": "GRAP,Odoo Community Association (OCA)",

bi_sql_editor/demo/res_groups_demo.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
66
-->
77
<odoo>
88
<record id="base.group_no_one" model="res.groups">
9-
<field name="users" eval="[(4, ref('base.user_admin'))]" />
9+
<field name="user_ids" eval="[Command.link(ref('base.user_admin'))]" />
1010
</record>
1111
<record id="sql_request_abstract.group_sql_request_user" model="res.groups">
12-
<field name="users" eval="[(4, ref('base.user_demo'))]" />
12+
<field name="user_ids" eval="[Command.link(ref('base.user_demo'))]" />
1313
</record>
1414
</odoo>

bi_sql_editor/models/bi_sql_view.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from psycopg2 import ProgrammingError
99
from psycopg2.sql import SQL, Identifier
1010

11-
from odoo import SUPERUSER_ID, _, api, fields, models
11+
from odoo import api, fields, models
1212
from odoo.exceptions import UserError, ValidationError
1313
from odoo.tools import sql
1414
from odoo.tools.safe_eval import safe_eval
@@ -163,7 +163,7 @@ def _check_index_materialized(self):
163163
for rec in self.filtered(lambda x: not x.is_materialized):
164164
if rec.bi_sql_view_field_ids.filtered(lambda x: x.is_index):
165165
raise UserError(
166-
_("You can not create indexes on non materialized views")
166+
self.env._("You can not create indexes on non materialized views")
167167
)
168168

169169
@api.constrains("view_order")
@@ -173,7 +173,7 @@ def _check_view_order(self):
173173
for vtype in rec.view_order.split(","):
174174
if vtype not in ("graph", "pivot", "list"):
175175
raise UserError(
176-
_("Only graph, pivot or list views are supported")
176+
self.env._("Only graph, pivot or list views are supported")
177177
)
178178

179179
# Compute Section
@@ -236,7 +236,7 @@ def write(self, vals):
236236
def _check_unlink_constraints(self):
237237
if any(view.state not in ("draft", "sql_valid") for view in self):
238238
raise UserError(
239-
_(
239+
self.env._(
240240
"You can only unlink draft views. "
241241
"If you want to delete them, first set them to draft."
242242
)
@@ -246,7 +246,7 @@ def copy(self, default=None):
246246
self.ensure_one()
247247
default = dict(default or {})
248248
if "name" not in default:
249-
default["name"] = _("%s (Copy)") % self.name
249+
default["name"] = self.env._("%s (Copy)", self.name)
250250
if "technical_name" not in default:
251251
default["technical_name"] = f"{self.technical_name}_copy"
252252
return super().copy(default=default)
@@ -260,8 +260,10 @@ def button_create_sql_view_and_model(self):
260260
)
261261
if bad_fields:
262262
raise ValidationError(
263-
_("Please set related models on the following fields %s")
264-
% ",".join(bad_fields.mapped("name"))
263+
self.env._(
264+
"Please set related models on the following fields %s",
265+
",".join(bad_fields.mapped("name")),
266+
)
265267
)
266268
# Create ORM and access
267269
sql_view._create_model_and_fields()
@@ -362,8 +364,11 @@ def _prepare_model_access(self):
362364
for group in self.group_ids:
363365
res.append(
364366
{
365-
"name": _("%(model_name)s Access %(full_name)s")
366-
% {"model_name": self.model_name, "full_name": group.full_name},
367+
"name": self.env._(
368+
"%(model_name)s Access %(full_name)s",
369+
model_name=self.model_name,
370+
full_name=group.full_name,
371+
),
367372
"model_id": self.model_id.id,
368373
"group_id": group.id,
369374
"perm_read": True,
@@ -377,8 +382,8 @@ def _prepare_model_access(self):
377382
def _prepare_cron(self):
378383
now = datetime.now()
379384
return {
380-
"name": _("Refresh Materialized View %s") % self.view_name,
381-
"user_id": SUPERUSER_ID,
385+
"name": self.env._("Refresh Materialized View %s", self.view_name),
386+
"user_id": api.SUPERUSER_ID,
382387
"model_id": self.env["ir.model"]
383388
.search([("model", "=", self._name)], limit=1)
384389
.id,
@@ -393,7 +398,7 @@ def _prepare_cron(self):
393398
def _prepare_rule(self):
394399
self.ensure_one()
395400
return {
396-
"name": _("Access %s") % self.name,
401+
"name": self.env._("Access %s", self.name),
397402
"model_id": self.model_id.id,
398403
"domain_force": self.domain_force,
399404
"global": True,
@@ -446,7 +451,7 @@ def _prepare_search_view(self):
446451
"model": self.model_id.model,
447452
"arch": """<?xml version="1.0"?>"""
448453
"""<search string="Analysis">{}"""
449-
"""<group expand="1" string="Group By">{}</group>"""
454+
"""<group>{}</group>"""
450455
"""</search>""".format(
451456
"".join(
452457
[x._prepare_search_field() for x in self.bi_sql_view_field_ids]
@@ -524,15 +529,13 @@ def _create_view(self):
524529
sql_view._refresh_size()
525530
except ProgrammingError as e:
526531
raise UserError(
527-
_(
532+
self.env._(
528533
"SQL Error while creating %(materialized_text)s"
529-
" VIEW %(view_name)s :\n %(error)s"
534+
" VIEW %(view_name)s :\n %(error)s",
535+
materialized_text=sql_view.materialized_text,
536+
view_name=sql_view.view_name,
537+
error=str(e),
530538
)
531-
% {
532-
"materialized_text": sql_view.materialized_text,
533-
"view_name": sql_view.view_name,
534-
"error": str(e),
535-
}
536539
) from e
537540

538541
def _create_index(self):
@@ -554,7 +557,7 @@ def _create_model_and_fields(self):
554557
sql_view.model_id = self.env["ir.model"].create(self._prepare_model()).id
555558
sql_view.rule_id = self.env["ir.rule"].create(self._prepare_rule()).id
556559
# Drop table, created by the ORM
557-
if sql.table_exists(self._cr, sql_view.view_name):
560+
if sql.table_exists(self.env.cr, sql_view.view_name):
558561
req = SQL("DROP TABLE {}").format(Identifier(sql_view.view_name))
559562
self._log_execute(req)
560563

@@ -656,7 +659,9 @@ def _check_execution(self):
656659

657660
if not self.bi_sql_view_field_ids:
658661
raise UserError(
659-
_("No Column was found.\nColumns name should be prefixed by 'x_'.")
662+
self.env._(
663+
"No Column was found.\nColumns name should be prefixed by 'x_'."
664+
)
660665
)
661666

662667
return columns

bi_sql_editor/models/bi_sql_view_field.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import re
66

7-
from odoo import _, api, fields, models
7+
from odoo import api, fields, models
88
from odoo.exceptions import UserError
99

1010

@@ -143,7 +143,7 @@ def _check_index_materialized(self):
143143
for rec in self.filtered(lambda x: x.is_index):
144144
if not rec.bi_sql_view_id.is_materialized:
145145
raise UserError(
146-
_("You can not create indexes on non materialized views")
146+
self.env._("You can not create indexes on non materialized views")
147147
)
148148

149149
# Compute Section
@@ -191,15 +191,15 @@ def create(self, vals_list):
191191
)
192192
return super().create(vals_list)
193193

194-
def unlink(self):
194+
@api.ondelete(at_uninstall=False)
195+
def _check_unlink_constraints(self):
195196
if self.filtered(lambda x: x.state in ("model_valid", "ui_valid")):
196197
raise UserError(
197-
_(
198+
self.env._(
198199
"Impossible to delete fields if the view"
199200
" is in the state 'Model Valid' or 'UI Valid'."
200201
)
201202
)
202-
return super().unlink()
203203

204204
# Custom Section
205205
@api.model

bi_sql_editor/security/ir.model.access.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ access_bi_sql_view_manager,access_bi_sql_view_manager,model_bi_sql_view,sql_requ
44
,,,,,,,
55
access_bi_sql_view_field_all,access_bi_sql_view_field_all,model_bi_sql_view_field,,0,0,0,0
66
access_bi_sql_view_field_manager,access_bi_sql_view_field_manager,model_bi_sql_view_field,sql_request_abstract.group_sql_request_manager,1,1,1,1
7+
access_ir_model_sql_request_manager,access_ir_model_sql_request_manager,base.model_ir_model,sql_request_abstract.group_sql_request_manager,1,0,0,0
8+
access_ir_actions_act_window_sql_request_manager,access_ir_actions_act_window_sql_request_manager,base.model_ir_actions_act_window,sql_request_abstract.group_sql_request_manager,1,0,0,0

0 commit comments

Comments
 (0)