Skip to content

Commit 1481787

Browse files
committed
Merge PR #938 into 18.0
Signed-off-by HviorForgeFlow
2 parents a3b5fc9 + 31d73be commit 1481787

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+60225
-0
lines changed

bi_sql_editor/README.rst

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
=============
2+
BI SQL Editor
3+
=============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:1acb226c184032febd7db6e48ee618c7e5a6899c4685aa78b5b2e7578ebd9ce9
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
20+
:target: https://github.com/OCA/reporting-engine/tree/18.0/bi_sql_editor
21+
:alt: OCA/reporting-engine
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-bi_sql_editor
24+
:alt: Translate me on Weblate
25+
.. |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=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module extends the functionality of reporting, to support creation
32+
of extra custom reports. It allows user to write a custom SQL request.
33+
(Generally, admin users)
34+
35+
Once written, a new model is generated, and user can map the selected
36+
field with odoo fields. Then user ends the process, creating new menu,
37+
action and graph view.
38+
39+
Technically, the module create SQL View (or materialized view, if option
40+
is checked). Materialized view duplicates datas, but request are
41+
fastest. If materialized view is enabled, this module will create a cron
42+
task to refresh the data).
43+
44+
By default, users member of 'SQL Request / User' can see all the views.
45+
You can specify extra groups that have the right to access to a specific
46+
view.
47+
48+
Warning
49+
-------
50+
51+
This module is intended for technician people in a company and for Odoo
52+
integrators.
53+
54+
It requires the user to know SQL syntax and Odoo models.
55+
56+
If you don't have such skills, do not try to use this module specially
57+
on a production environment.
58+
59+
Use Cases
60+
---------
61+
62+
this module is interesting for the following use cases
63+
64+
- You want to realize technical SQL requests, that Odoo framework
65+
doesn't allow (For exemple, UNION with many SELECT) A typical use
66+
case is if you want to have Sale Orders and PoS Orders datas in a
67+
same table
68+
- You want to customize an Odoo report, removing some useless fields
69+
and adding some custom ones. In that case, you can simply select the
70+
fields of the original report (sale.report model for exemple), and
71+
add your custom fields
72+
- You have a lot of data, and classical SQL Views have very bad
73+
performance. In that case, MATERIALIZED VIEW will be a good solution
74+
to reduce display duration
75+
76+
**Table of contents**
77+
78+
.. contents::
79+
:local:
80+
81+
Configuration
82+
=============
83+
84+
- Go to Dashboard / Configuration / SQL Views
85+
86+
- tip your SQL request
87+
88+
|image1|
89+
90+
- Select the group(s) that could have access to the view
91+
92+
|image2|
93+
94+
Optionnaly, you can add a domain.
95+
96+
A tipical domain in a multi company context is to write
97+
``['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]``
98+
to make reporting depending on the current companies of the user.
99+
100+
- Click on the button 'Validate SQL Expression'
101+
102+
- Once the sql request checked, the module analyses the column of the
103+
view, and propose field mapping. For each field, you can decide to
104+
create an index and set if it will be displayed on the pivot graph as
105+
a column, a row or a measure.
106+
107+
|image3|
108+
109+
- Click on the button 'Create SQL elements'. (this step could take a
110+
while, if view is materialized)
111+
112+
- If it's a MATERIALIZED view:
113+
114+
- a cron task is created to refresh the view. You can so define
115+
the frequency of the refresh.
116+
- the size of view (and the indexes is displayed)
117+
118+
|image4|
119+
120+
- Before applying the final step, you will need to add a specific
121+
Parent Menu to use when creating the UI Menu for the report. By
122+
default, it will be set with the ``SQL Views`` menu, which can be
123+
changed before creating the UI elements in order to have the report
124+
accessible from a different place within Odoo.
125+
126+
- Finally, click on 'Create UI', to create new menu, action, graph view
127+
and search view.
128+
129+
.. |image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/01_sql_request.png
130+
.. |image2| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/02_security_access.png
131+
.. |image3| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/03_field_mapping.png
132+
.. |image4| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/04_materialized_view_setting.png
133+
134+
Usage
135+
=====
136+
137+
To use this module, you need to:
138+
139+
1. Go to 'Dashboards > SQL Reports'
140+
2. Select the desired report
141+
142+
..
143+
144+
|usage-image1|
145+
146+
- You can switch to 'Graph' or 'tree' views as any report.
147+
148+
.. |usage-image1| image:: https://raw.githubusercontent.com/OCA/reporting-engine/18.0/bi_sql_editor/static/description/05_reporting_pivot.png
149+
150+
Bug Tracker
151+
===========
152+
153+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
154+
In case of trouble, please check there if your issue has already been reported.
155+
If you spotted it first, help us to smash it by providing a detailed and welcomed
156+
`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**>`_.
157+
158+
Do not contact contributors directly about support or help with technical issues.
159+
160+
Credits
161+
=======
162+
163+
Authors
164+
-------
165+
166+
* GRAP
167+
168+
Contributors
169+
------------
170+
171+
- Sylvain LE GAL (https://twitter.com/legalsylvain)
172+
173+
- Richard deMeester, WilldooIT (http://www.willdooit.com/)
174+
175+
- David James, WilldooIT (http://www.willdooit.com/)
176+
177+
- Guillem Casassas guillem.casassas@forgeflow.com
178+
179+
- Thien Vo thienvh@trobz.com
180+
181+
- This module is highly inspired by the work of
182+
183+
- Onestein: (http://www.onestein.nl/) Module:
184+
OCA/server-tools/bi_view_editor. Link:
185+
https://github.com/OCA/reporting-engine/tree/9.0/bi_view_editor
186+
- Anybox: (https://anybox.fr/) Module :
187+
OCA/server-tools/materialized_sql_view link:
188+
https://github.com/OCA/server-tools/pull/110
189+
- GRAP, Groupement Régional Alimentaire de Proximité:
190+
(http://www.grap.coop/) Module:
191+
grap/odoo-addons-misc/pos_sale_reporting link:
192+
https://github.com/grap/odoo-addons-misc/tree/7.0/pos_sale_reporting
193+
194+
Other credits
195+
-------------
196+
197+
The migration of this module from 17.0 to 18.0 was financially supported
198+
by Camptocamp.
199+
200+
Maintainers
201+
-----------
202+
203+
This module is maintained by the OCA.
204+
205+
.. image:: https://odoo-community.org/logo.png
206+
:alt: Odoo Community Association
207+
:target: https://odoo-community.org
208+
209+
OCA, or the Odoo Community Association, is a nonprofit organization whose
210+
mission is to support the collaborative development of Odoo features and
211+
promote its widespread use.
212+
213+
.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
214+
:target: https://github.com/legalsylvain
215+
:alt: legalsylvain
216+
217+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
218+
219+
|maintainer-legalsylvain|
220+
221+
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/18.0/bi_sql_editor>`_ project on GitHub.
222+
223+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

bi_sql_editor/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2+
3+
from . import models
4+
from .hooks import uninstall_hook

bi_sql_editor/__manifest__.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
{
6+
"name": "BI SQL Editor",
7+
"summary": "BI Views builder, based on Materialized or Normal SQL Views",
8+
"version": "18.0.1.0.0",
9+
"license": "AGPL-3",
10+
"category": "Reporting",
11+
"author": "GRAP,Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/reporting-engine",
13+
"depends": [
14+
"spreadsheet_dashboard",
15+
"sql_request_abstract",
16+
],
17+
"data": [
18+
"security/ir.model.access.csv",
19+
"views/view_bi_sql_view.xml",
20+
],
21+
"demo": ["demo/res_groups_demo.xml", "demo/bi_sql_view_demo.xml"],
22+
"installable": True,
23+
"uninstall_hook": "uninstall_hook",
24+
"maintainers": ["legalsylvain"],
25+
}
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Copyright (C) 2014 - Today GRAP (http://www.grap.coop)
4+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
6+
-->
7+
<odoo noupdate="1">
8+
<record id="incorrect_sql_view" model="bi.sql.view">
9+
<field name="name">Draft Incorrect SQL View</field>
10+
<field name="technical_name">incorrect_view</field>
11+
<field
12+
name="query"
13+
><![CDATA[
14+
SELECT *
15+
FROM unexisting_table
16+
ORDER BY unexisting_field
17+
]]>
18+
</field>
19+
</record>
20+
<record id="partner_sql_view" model="bi.sql.view">
21+
<field name="name">Partners View</field>
22+
<field name="technical_name">partners_view</field>
23+
<field name="is_materialized" eval="True" />
24+
<field
25+
name="query"
26+
><![CDATA[
27+
SELECT
28+
name as x_name,
29+
street as x_street,
30+
company_id as x_company_id
31+
FROM res_partner
32+
ORDER BY name
33+
]]>
34+
</field>
35+
</record>
36+
<record id="module_sql_view" model="bi.sql.view">
37+
<field name="name">Modules by Authors</field>
38+
<field name="technical_name">modules_view</field>
39+
<field name="is_materialized" eval="0" />
40+
<field
41+
name="query"
42+
><![CDATA[
43+
SELECT
44+
name as x_name,
45+
case
46+
when author ilike '%OpenERP SA%' THEN 'Odoo SA'
47+
when author ilike '%Odoo Community Association (OCA)%' THEN 'OCA'
48+
else 'Undefined Author' END as x_author_type
49+
FROM ir_module_module
50+
]]>
51+
</field>
52+
</record>
53+
</odoo>
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Copyright (C) 2014 - Today GRAP (http://www.grap.coop)
4+
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
6+
-->
7+
<odoo>
8+
<record id="base.group_no_one" model="res.groups">
9+
<field name="users" eval="[(4, ref('base.user_admin'))]" />
10+
</record>
11+
<record id="sql_request_abstract.group_sql_request_user" model="res.groups">
12+
<field name="users" eval="[(4, ref('base.user_demo'))]" />
13+
</record>
14+
</odoo>

bi_sql_editor/hooks.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2015-2017 Onestein (<http://www.onestein.eu>)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
5+
def uninstall_hook(env):
6+
recs = env["bi.sql.view"].search([])
7+
for rec in recs:
8+
rec.button_set_draft()

0 commit comments

Comments
 (0)