Skip to content

Commit 4c00443

Browse files
committed
[IMP] bi_view_editor: pre-commit auto fixes
1 parent a23dc90 commit 4c00443

22 files changed

+266
-270
lines changed

bi_view_editor/README.rst

+77-73
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ BI View Editor
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
20-
:target: https://github.com/OCA/reporting-engine/tree/16.0/bi_view_editor
20+
:target: https://github.com/OCA/reporting-engine/tree/18.0/bi_view_editor
2121
:alt: OCA/reporting-engine
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-bi_view_editor
23+
:target: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-bi_view_editor
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -33,14 +33,12 @@ execute their own reports without the need to code.
3333

3434
Purpose:
3535

36-
* The BI View Editor is used to create reports not already contained in the
37-
standard Odoo, combining data from existing sources.
38-
39-
* It has been designed to be used by users with little or no knowledge of
40-
the technical architecture of Odoo. Users visually link business objects
41-
and select the fields to visualize.
42-
43-
* The BI View Editor offers users different types of representations,
36+
- The BI View Editor is used to create reports not already contained in
37+
the standard Odoo, combining data from existing sources.
38+
- It has been designed to be used by users with little or no knowledge
39+
of the technical architecture of Odoo. Users visually link business
40+
objects and select the fields to visualize.
41+
- The BI View Editor offers users different types of representations,
4442
including tree, graph, pivot views.
4543

4644
**Table of contents**
@@ -54,19 +52,21 @@ Installation
5452
In the Odoo configuration file add ``bi_view_editor`` in the list
5553
``server_wide_modules``:
5654

57-
.. code-block:: ini
55+
.. code:: ini
5856
59-
[options]
60-
(...)
61-
server_wide_modules = web,bi_view_editor
62-
(...)
57+
[options]
58+
(...)
59+
server_wide_modules = web,bi_view_editor
60+
(...)
6361
64-
Alternatively specify ``--load=bi_view_editor`` when starting Odoo by command line.
62+
Alternatively specify ``--load=bi_view_editor`` when starting Odoo by
63+
command line.
6564

66-
Optionally it is possible to enable the view of the ER Diagram. For this you
67-
need to install `Graphviz`, an open source graph visualization software:
65+
Optionally it is possible to enable the view of the ER Diagram. For this
66+
you need to install Graphviz, an open source graph visualization
67+
software:
6868

69-
.. code-block:: bash
69+
.. code:: bash
7070
7171
``sudo apt-get install graphviz``
7272
@@ -76,97 +76,101 @@ Usage
7676
To graphically design your analysis data-set:
7777

7878
- From the Dashboards menu, select "Custom BI Views"
79-
- BI Views creation is restricted to members of "BI View Editor Manager" group.
80-
You can add this group to a user in User form, Access Rights, Technical section.
79+
- BI Views creation is restricted to members of "BI View Editor Manager"
80+
group. You can add this group to a user in User form, Access Rights,
81+
Technical section.
8182
- Browse trough the business objects in the "Query Builder" tab
8283
- Pick the interesting fields (Drag & Drop)
83-
- For each selected field, right-click on the Options column and select whether
84-
it's a row, column or measure; if you want to remove the field from the list
85-
view, unflag the checkbox ´List´ in the Options column
84+
- For each selected field, right-click on the Options column and select
85+
whether it's a row, column or measure; if you want to remove the field
86+
from the list view, unflag the checkbox ´List´ in the Options column
8687
- Save and click "Generate BI View"
8788
- Click "Open BI View" to view the result
8889

8990
To access the created BI View with a dedicated menu:
9091

91-
- If module Dashboard (board) is installed, the standard "Add to My Dashboard"
92-
functionality would be available
93-
- "Create a menu" is restricted to members of "BI View Editor Manager" group.
94-
- Click "Create a menu" to create a new menu item directly linked to your new
95-
BI view (this feature is available in developer mode); when the BI view is
96-
reset back to draft this menu will be removed, and you will need to re-create
97-
the menu entry.
98-
99-
A more advanced UI is also available under the "Details" tab. It provides extra
100-
possibilities for more advanced users, like to use LEFT JOIN instead of the
101-
default INNER JOIN.
102-
103-
It also possible to improve the IDs generation for new views by adding an
104-
`Over Condition` in the "SQL" tab, see https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS
105-
for further details.
106-
For instance, an ORDER BY clause helps preventing unreliable behavior when
107-
filtering the generated views.
92+
- If module Dashboard (board) is installed, the standard "Add to My
93+
Dashboard" functionality would be available
94+
- "Create a menu" is restricted to members of "BI View Editor Manager"
95+
group.
96+
- Click "Create a menu" to create a new menu item directly linked to
97+
your new BI view (this feature is available in developer mode); when
98+
the BI view is reset back to draft this menu will be removed, and you
99+
will need to re-create the menu entry.
100+
101+
A more advanced UI is also available under the "Details" tab. It
102+
provides extra possibilities for more advanced users, like to use LEFT
103+
JOIN instead of the default INNER JOIN.
104+
105+
It also possible to improve the IDs generation for new views by adding
106+
an Over Condition in the "SQL" tab, see
107+
https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS
108+
for further details. For instance, an ORDER BY clause helps preventing
109+
unreliable behavior when filtering the generated views.
108110

109111
Known issues / Roadmap
110112
======================
111113

112-
* Non-stored fields and many2many fields are not supported.
113-
* Provide a tutorial (eg. a working example of usage).
114-
* Find better ways to extend the *_auto_init()* without override.
115-
* Possibly avoid the monkey patches.
116-
* Data the user has no access to (e.g. in a multi company situation) can be
117-
viewed by making a view. Would be nice if models available to select when
118-
creating a view are limited to the ones that have intersecting groups.
119-
* As of Odoo 16, translations of the name of a BI View and of the field
120-
descriptions do not work as expected: the translated strings are selected
121-
(by the user's language) when the view is generated (and stored as their
122-
``en_US`` value) instead of when it is displayed.
114+
- Non-stored fields and many2many fields are not supported.
115+
- Provide a tutorial (eg. a working example of usage).
116+
- Find better ways to extend the *\_auto_init()* without override.
117+
- Possibly avoid the monkey patches.
118+
- Data the user has no access to (e.g. in a multi company situation) can
119+
be viewed by making a view. Would be nice if models available to
120+
select when creating a view are limited to the ones that have
121+
intersecting groups.
122+
- As of Odoo 16, translations of the name of a BI View and of the field
123+
descriptions do not work as expected: the translated strings are
124+
selected (by the user's language) when the view is generated (and
125+
stored as their ``en_US`` value) instead of when it is displayed.
123126

124127
Bug Tracker
125128
===========
126129

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

132135
Do not contact contributors directly about support or help with technical issues.
133136

134137
Credits
135138
=======
136139

137140
Authors
138-
~~~~~~~
141+
-------
139142

140143
* Onestein
141144

142145
Contributors
143-
~~~~~~~~~~~~
146+
------------
144147

145-
* Simon Janssens <[email protected]>
146-
* Diego Luis Neto <[email protected]>
147-
* Dennis Sluijk <[email protected]>
148-
* Kevin Graveman <[email protected]>
149-
* Richard Dijkstra <[email protected]>
150-
* Andrea Stirpe <[email protected]>
151-
* Antonio Esposito <[email protected]>
152-
* Jordi Ballester Alomar <[email protected]>
153-
* Italo LOPES <[email protected]>
154-
* `Coop IT Easy SC <https://coopiteasy.be>`_:
148+
- Simon Janssens <[email protected]>
149+
- Diego Luis Neto <[email protected]>
150+
- Dennis Sluijk <[email protected]>
151+
- Kevin Graveman <[email protected]>
152+
- Richard Dijkstra <[email protected]>
153+
- Andrea Stirpe <[email protected]>
154+
- Antonio Esposito <[email protected]>
155+
- Jordi Ballester Alomar <[email protected]>
156+
- Italo LOPES <[email protected]>
157+
- `Coop IT Easy SC <https://coopiteasy.be>`__:
155158

156-
* hugues de keyzer
159+
- hugues de keyzer
157160

158161
Other credits
159-
~~~~~~~~~~~~~
162+
-------------
160163

161164
Funders
162-
-------
165+
~~~~~~~
163166

164-
The development of this module for Odoo 11.0 has been financially supported by:
167+
The development of this module for Odoo 11.0 has been financially
168+
supported by:
165169

166-
* IDEAL Connaissances SAS https://www.idealconnaissances.com
170+
- IDEAL Connaissances SAS https://www.idealconnaissances.com
167171

168172
Maintainers
169-
~~~~~~~~~~~
173+
-----------
170174

171175
This module is maintained by the OCA.
172176

@@ -178,6 +182,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
178182
mission is to support the collaborative development of Odoo features and
179183
promote its widespread use.
180184

181-
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/bi_view_editor>`_ project on GitHub.
185+
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/18.0/bi_view_editor>`_ project on GitHub.
182186

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

bi_view_editor/models/bve_view.py

+13-32
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _create_view_arch(self):
177177

178178
def _get_field_def(line):
179179
field_type = line.view_field_type
180-
return '<field name="{}" type="{}" />'.format(line.name, field_type)
180+
return f'<field name="{line.name}" type="{field_type}" />'
181181

182182
bve_field_lines = self.field_ids.filtered("view_field_type")
183183
return list(map(_get_field_def, bve_field_lines))
@@ -187,8 +187,8 @@ def _create_tree_view_arch(self):
187187

188188
def _get_field_attrs(line):
189189
attr = line.list_attr
190-
res = attr and '{}="{}"'.format(attr, line.description) or ""
191-
return '<field name="{}" {} />'.format(line.name, res)
190+
res = attr and f'{attr}="{line.description}"' or ""
191+
return f'<field name="{line.name}" {res} />'
192192

193193
bve_field_lines = self.field_ids.filtered(lambda l: l.in_list)
194194
return list(map(_get_field_attrs, bve_field_lines.sorted("sequence")))
@@ -212,9 +212,7 @@ def _create_bve_view(self):
212212
<pivot string="Pivot Analysis">
213213
{}
214214
</pivot>
215-
""".format(
216-
"".join(self._create_view_arch())
217-
),
215+
""".format("".join(self._create_view_arch())),
218216
},
219217
{
220218
"name": "Graph Analysis",
@@ -226,9 +224,7 @@ def _create_bve_view(self):
226224
type="bar" stacked="True">
227225
{}
228226
</graph>
229-
""".format(
230-
"".join(self._create_view_arch())
231-
),
227+
""".format("".join(self._create_view_arch())),
232228
},
233229
{
234230
"name": "Search BI View",
@@ -239,9 +235,7 @@ def _create_bve_view(self):
239235
<search>
240236
{}
241237
</search>
242-
""".format(
243-
"".join(self._create_view_arch())
244-
),
238+
""".format("".join(self._create_view_arch())),
245239
},
246240
]
247241
)
@@ -257,9 +251,7 @@ def _create_bve_view(self):
257251
<tree create="false">
258252
{}
259253
</tree>
260-
""".format(
261-
"".join(self._create_tree_view_arch())
262-
),
254+
""".format("".join(self._create_tree_view_arch())),
263255
}
264256
)
265257

@@ -344,7 +336,7 @@ def _compute_sql_query(self):
344336
table = line.table_alias
345337
select = line.field_id.name
346338
as_name = line.name
347-
select_str += ",\n {}.{} AS {}".format(table, select, as_name)
339+
select_str += f",\n {table}.{select} AS {as_name}"
348340

349341
if line.table_alias not in tables_map:
350342
table = self.env[line.field_id.model_id.model]._table
@@ -354,34 +346,23 @@ def _compute_sql_query(self):
354346
if not bve_view.relation_ids and bve_view.field_ids:
355347
first_line = bve_view.field_ids[0]
356348
table = tables_map[first_line.table_alias]
357-
from_str = "{} AS {}".format(table, first_line.table_alias)
349+
from_str = f"{table} AS {first_line.table_alias}"
358350
for line in bve_view.relation_ids:
359351
table = tables_map[line.table_alias]
360-
table_format = "{} AS {}".format(table, line.table_alias)
352+
table_format = f"{table} AS {line.table_alias}"
361353
if not from_str:
362354
from_str += table_format
363355
seen.add(line.table_alias)
364356
if line.table_alias not in seen:
365357
seen.add(line.table_alias)
366358
from_str += "\n"
367359
from_str += " LEFT" if line.left_join else ""
368-
from_str += " JOIN {} ON {}.id = {}.{}".format(
369-
table_format,
370-
line.join_node,
371-
line.table_alias,
372-
line.field_id.name,
373-
)
360+
from_str += f" JOIN {table_format} ON {line.join_node}.id = {line.table_alias}.{line.field_id.name}"
374361
if line.join_node not in seen:
375362
from_str += "\n"
376363
seen.add(line.join_node)
377364
from_str += " LEFT" if line.left_join else ""
378-
from_str += " JOIN {} AS {} ON {}.{} = {}.id".format(
379-
tables_map[line.join_node],
380-
line.join_node,
381-
line.table_alias,
382-
line.field_id.name,
383-
line.join_node,
384-
)
365+
from_str += f" JOIN {tables_map[line.join_node]} AS {line.join_node} ON {line.table_alias}.{line.field_id.name} = {line.join_node}.id"
385366
bve_view.query = """SELECT %s\n\nFROM %s
386367
""" % (
387368
AsIs(select_str),
@@ -457,7 +438,7 @@ def _check_groups_consistency(self):
457438
)
458439
group_list = ""
459440
for group in access_records.mapped("group_id"):
460-
group_list += " * {}\n".format(group.full_name)
441+
group_list += f" * {group.full_name}\n"
461442
msg_title = _(
462443
'The model "%s" cannot be accessed by users with the selected groups only.'
463444
) % (line_model.name,)

bi_view_editor/models/bve_view_line.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ def _compute_name(self):
8383
for line in self:
8484
line.name = False
8585
if line.field_id:
86-
line.name = "x_bve_{}_{}".format(line.table_alias, line.field_id.name)
86+
line.name = f"x_bve_{line.table_alias}_{line.field_id.name}"
8787

8888
@api.depends("field_id")
8989
def _compute_model_field_name(self):
9090
for line in self:
9191
line.field_name = False
9292
if line.field_id:
93-
line.field_name = "{} ({})".format(line.description, line.model_name)
93+
line.field_name = f"{line.description} ({line.model_name})"
9494

9595
def _prepare_field_vals(self):
9696
vals_list = []

bi_view_editor/models/models.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def _bi_view(_name):
1818

1919

2020
def _auto_init(self):
21-
2221
# This monkey patch is meant to fix an error (probably
2322
# introduced by https://github.com/odoo/odoo/pull/15412), while
2423
# running an update all. The _auto_init() method invoked during

bi_view_editor/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"

bi_view_editor/readme/CONTRIBUTORS.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- Simon Janssens \<<[email protected]>\>
2+
- Diego Luis Neto \<<[email protected]>\>
3+
- Dennis Sluijk \<<[email protected]>\>
4+
- Kevin Graveman \<<[email protected]>\>
5+
- Richard Dijkstra \<<[email protected]>\>
6+
- Andrea Stirpe \<<[email protected]>\>
7+
- Antonio Esposito \<<[email protected]>\>
8+
- Jordi Ballester Alomar \<<[email protected]>\>
9+
- Italo LOPES \<<[email protected]>\>
10+
- [Coop IT Easy SC](https://coopiteasy.be):
11+
- hugues de keyzer

0 commit comments

Comments
 (0)