Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] bi_view_editor #960

Open
wants to merge 45 commits into
base: 18.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1bf32f6
Initial commit bi_view_editor V9
astirpe Mar 6, 2017
4a8b6be
[MIG+IMP] bi_view_editor: Migration to v10 + enhancements
astirpe Mar 6, 2017
391315d
OCA Transbot updated translations from Transifex
oca-transbot Jan 27, 2018
aaed8fc
[MIG] bi_view_editor: Migration to 11.0
tarteo Mar 22, 2018
ba76d49
[FIX] bi_view_editor: Apostrophe + migration script
SimoRubi Aug 14, 2018
f4800cf
Remove logger warnings during update all
astirpe Aug 29, 2018
95bcdbe
[FIX] Field widget, new readme + Make enabled in list view default true
tarteo Sep 4, 2018
988dea8
Drop bi views when uninstalling module
astirpe Sep 7, 2018
f3ae3e1
[UPD] README.rst
OCA-git-bot Nov 27, 2018
29a2f1f
[UPD] Update bi_view_editor.pot
oca-travis Nov 27, 2018
ad8cac7
[12.0][MIG] bi_view_editor
astirpe Jun 6, 2019
f97ab1e
Add extra functionalities
astirpe Jun 18, 2019
a583ebb
[UPD] Update bi_view_editor.pot
oca-travis Nov 29, 2019
58e4a42
[UPD] README.rst
OCA-git-bot Nov 29, 2019
486857b
Update translation files
oca-transbot Jan 9, 2020
57f71b0
bi_view_editor: window functions without ORDER BY clause do not have …
SimoRubi Apr 23, 2020
b369c32
bi_view_editor: Better error message if the query is not correct
SimoRubi May 7, 2020
4f76c39
pre-commit
astirpe Sep 9, 2020
2c31b02
[13.0][MIG] bi_view_editor
astirpe Sep 9, 2020
ca6299a
[14.0][MIG] bi_view_editor
astirpe Oct 20, 2020
4991510
[UPD] Update bi_view_editor.pot
oca-travis Apr 21, 2021
3301a1b
[UPD] README.rst
OCA-git-bot Apr 21, 2021
737a7e9
bi_view_editor: add deb external dependencies
sbidoul Feb 21, 2022
bf7de97
Translated using Weblate (Italian)
francesco-ooops Jul 6, 2022
5120fad
[MIG] bi_view_editor: Migration to 15.0
Mar 8, 2023
63323f7
[UPD] Update bi_view_editor.pot
Mar 9, 2023
7365c5f
[UPD] README.rst
OCA-git-bot Mar 9, 2023
fb8d696
[MIG] bi_view_editor: migration to 16.0
huguesdk Oct 25, 2023
0bbfc66
[UPD] Update bi_view_editor.pot
Nov 7, 2023
682d576
[BOT] post-merge updates
OCA-git-bot Nov 7, 2023
c8a1ccd
Update translation files
weblate Nov 7, 2023
6ded4af
[IMP] bi_view_editor: Restrict access to BI View Editor Managers
yankinmax Oct 19, 2023
066ab47
[UPD] Update bi_view_editor.pot
Nov 7, 2023
cb167e5
[BOT] post-merge updates
OCA-git-bot Nov 7, 2023
d6a11ed
Update translation files
weblate Nov 7, 2023
db2a98d
Translated using Weblate (Spanish)
Ivorra78 Nov 7, 2023
2e1d0ae
Translated using Weblate (Italian)
mymage Nov 9, 2023
dd24c0b
Translated using Weblate (Japanese)
liuhehe1995 Jan 12, 2024
81aa9a6
Translated using Weblate (Italian)
mymage Jan 18, 2024
34057cd
[UPD] Update bi_view_editor.pot
Apr 22, 2024
dc8e6c6
Update translation files
weblate Apr 22, 2024
11b08bb
Translated using Weblate (Italian)
mymage Apr 29, 2024
a23dc90
Translated using Weblate (Swedish)
jakobkrabbe Jun 27, 2024
4c00443
[IMP] bi_view_editor: pre-commit auto fixes
cormaza Jan 6, 2025
11deda8
[MIG] bi_view_editor: Migration to 18.0
cormaza Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bi_view_editor: Better error message if the query is not correct
SimoRubi authored and cormaza committed Jan 6, 2025
commit b369c327ae116ab2b4816bad5063c4dd183361eb
12 changes: 10 additions & 2 deletions bi_view_editor/models/bve_view.py
Original file line number Diff line number Diff line change
@@ -295,8 +295,16 @@ def _create_sql_view(self):
self._cr.execute('DROP TABLE IF EXISTS %s', (AsIs(view_name), ))

# create postgres view
self.env.cr.execute('CREATE or REPLACE VIEW %s as (%s)', (
AsIs(view_name), AsIs(query), ))
try:
with self.env.cr.savepoint():
self.env.cr.execute('CREATE or REPLACE VIEW %s as (%s)', (
AsIs(view_name), AsIs(query), ))
except Exception as e:
raise UserError(
_("Error creating the view '{query}':\n{error}")
.format(
query=query,
error=e))

@api.depends('line_ids', 'state', 'over_condition')
def _compute_sql_query(self):
1 change: 0 additions & 1 deletion bi_view_editor/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -5,4 +5,3 @@
* Data the user has no access to (e.g. in a multi company situation) can be
viewed by making a view. Would be nice if models available to select when
creating a view are limited to the ones that have intersecting groups.
* Raise a warning in case the SQL query is not correct.
22 changes: 22 additions & 0 deletions bi_view_editor/tests/test_bi_view.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

import odoo
from odoo.tests.common import TransactionCase
from odoo.tools import mute_logger
from odoo.exceptions import UserError, ValidationError
from ..hooks import post_load, uninstall_hook

@@ -407,3 +408,24 @@ def test_19_field_selection(self):
bi_view1 = self.env['bve.view'].create(vals)
bi_view1.action_create()
self.assertEqual(len(bi_view1.line_ids), 4)

@mute_logger('odoo.sql_db')
def test_20_broken_view(self):
"""
Create a broken query, a nice UserError should be raised.
odoo.sql_db logger is muted to avoid the
ERROR: bad_query line in the logs.
"""
vals = self.bi_view1_vals
vals.update({
'name': 'Test View broken',
'over_condition': 'bad SQL code',
})
bi_view = self.env['bve.view'].create(vals)
with self.assertRaises(UserError) as ue:
bi_view.action_create()

self.assertEqual(bi_view.state, 'draft')
self.assertIn(bi_view.over_condition, str(ue.exception))
# remove view
bi_view.unlink()