[MIG] sql_request_abstract: Migration to 17.0

This commit is contained in:
chien
2023-12-21 10:15:09 +07:00
committed by thien
parent 8b5b181811
commit b125c4ad9c
16 changed files with 134 additions and 149 deletions

View File

@@ -17,37 +17,40 @@ SQL Request Abstract
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/16.0/sql_request_abstract
:target: https://github.com/OCA/reporting-engine/tree/17.0/sql_request_abstract
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-sql_request_abstract
:target: https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-sql_request_abstract
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module provides an abstract model to manage SQL Select requests on database.
It is not usefull for itself. You can see an exemple of implementation in the
'sql_export' module. (same repository).
This module provides an abstract model to manage SQL Select requests on
database. It is not usefull for itself. You can see an exemple of
implementation in the 'sql_export' module. (same repository).
Implemented features
~~~~~~~~~~~~~~~~~~~~
--------------------
* Add some restrictions in the sql request:
* you can only read datas. No update, deletion or creation are possible.
* some tables are not allowed, because they could contains clear password
or keys. For the time being ('ir_config_parameter').
- Add some restrictions in the sql request:
* The request can be in a 'draft' or a 'SQL Valid' status. To be valid,
the request has to be cleaned, checked and tested. All of this operations
can be disabled in the inherited modules.
- you can only read datas. No update, deletion or creation are
possible.
- some tables are not allowed, because they could contains clear
password or keys. For the time being ('ir_config_parameter').
* This module two new groups:
* SQL Request / User : Can see all the sql requests by default and execute
them, if they are valid.
* SQL Request / Manager : has full access on sql requests.
- The request can be in a 'draft' or a 'SQL Valid' status. To be valid,
the request has to be cleaned, checked and tested. All of this
operations can be disabled in the inherited modules.
- This module two new groups:
- SQL Request / User : Can see all the sql requests by default and
execute them, if they are valid.
- SQL Request / Manager : has full access on sql requests.
**Table of contents**
@@ -59,27 +62,27 @@ Usage
Inherit the model:
.. code-block:: python
.. code:: python
from odoo import models
from odoo import models
class MyModel(models.model)
_name = 'my.model'
_inherit = ['sql.request.mixin']
class MyModel(models.model)
_name = 'my.model'
_inherit = ['sql.request.mixin']
_sql_request_groups_relation = 'my_model_groups_rel'
_sql_request_groups_relation = 'my_model_groups_rel'
_sql_request_users_relation = 'my_model_users_rel'
_sql_request_users_relation = 'my_model_users_rel'
See implementations in the modules ``bi_sql_editor`` and ``sql_export``. (same OCA/reporting-engine repository)
See implementations in the modules ``bi_sql_editor`` and ``sql_export``.
(same OCA/reporting-engine repository)
Development
===========
This module add the 'pgsql' mode syntax for the ace widget.
(the ace widget is used in odoo web module, but only with
the xml and python mode).
This module add the 'pgsql' mode syntax for the ace widget. (the ace
widget is used in odoo web module, but only with the xml and python
mode).
The file is a copy of the file present here
(https://github.com/ajaxorg/ace-builds/blob/v1.12.3/src/mode-pgsql.js
@@ -91,7 +94,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20sql_request_abstract%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20sql_request_abstract%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -99,21 +102,22 @@ Credits
=======
Authors
~~~~~~~
-------
* GRAP
* Akretion
Contributors
~~~~~~~~~~~~
------------
* Florian da Costa <florian.dacosta@akretion.com>
* Sylvain LE GAL (https://twitter.com/legalsylvain)
* Alfadil Tabar (alfadil.tabar@gmail.com)
* Helly kapatel <helly.kapatel@initos.com>
- Florian da Costa <florian.dacosta@akretion.com>
- Sylvain LE GAL (https://twitter.com/legalsylvain)
- Alfadil Tabar (alfadil.tabar@gmail.com)
- Helly kapatel <helly.kapatel@initos.com>
- Nguyen Minh Chien <chien@trobz.com>
Maintainers
~~~~~~~~~~~
-----------
This module is maintained by the OCA.
@@ -133,6 +137,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-legalsylvain|
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/sql_request_abstract>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/17.0/sql_request_abstract>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,2 +1 @@
from . import controllers
from . import models

View File

@@ -4,7 +4,7 @@
{
"name": "SQL Request Abstract",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "GRAP,Akretion,Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://github.com/OCA/reporting-engine",
@@ -18,5 +18,13 @@
"security/ir.model.access.csv",
"views/view_sql_request_mixin.xml",
],
"assets": {
"web._assets_core": [
"sql_request_abstract/static/src/js/code_editor.esm.js",
],
"web.ace_lib": [
"sql_request_abstract/static/lib/ace/mode-pgsql.js",
],
},
"installable": True,
}

View File

@@ -1 +0,0 @@
from . import main

View File

@@ -1,28 +0,0 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import werkzeug
from odoo import http
from odoo.http import request
from odoo.tools.misc import file_open
from odoo.addons.web.controllers.webclient import WebClient
class SqlRequestAbstractWebClient(WebClient):
# if a field, widget="ace" option="{'mode': 'xxx'}"
# is present, The ace lib (odoo/addons/web/static/lib/ace)
# will generate a call to /web/static/lib/ace/mode-xxx.js
# to load the javascript syntax file.
# We catch this call and redirect on the correct path
@http.route("/web/static/lib/ace/mode-pgsql.js", type="http", auth="none")
def call_mode_pgsql_file(self):
return http.Response(
werkzeug.wsgi.wrap_file(
request.httprequest.environ,
file_open("sql_request_abstract/static/lib/ace/mode-pgsql.js", "rb"),
),
content_type="application/javascript; charset=utf-8",
headers=[("Cache-Control", f"max-age={http.STATIC_CACHE}")],
direct_passthrough=True,
)

View File

@@ -0,0 +1,5 @@
- Florian da Costa \<<florian.dacosta@akretion.com>\>
- Sylvain LE GAL (<https://twitter.com/legalsylvain>)
- Alfadil Tabar (<alfadil.tabar@gmail.com>)
- Helly kapatel \<<helly.kapatel@initos.com>\>
- Nguyen Minh Chien \<<chien@trobz.com>\>

View File

@@ -1,4 +0,0 @@
* Florian da Costa <florian.dacosta@akretion.com>
* Sylvain LE GAL (https://twitter.com/legalsylvain)
* Alfadil Tabar (alfadil.tabar@gmail.com)
* Helly kapatel <helly.kapatel@initos.com>

View File

@@ -0,0 +1,20 @@
This module provides an abstract model to manage SQL Select requests on
database. It is not usefull for itself. You can see an exemple of
implementation in the 'sql_export' module. (same repository).
## Implemented features
- Add some restrictions in the sql request:
- you can only read datas. No update, deletion or creation are
possible.
- some tables are not allowed, because they could contains clear
password or keys. For the time being ('ir_config_parameter').
- The request can be in a 'draft' or a 'SQL Valid' status. To be valid,
the request has to be cleaned, checked and tested. All of this
operations can be disabled in the inherited modules.
- This module two new groups:
- SQL Request / User : Can see all the sql requests by default and
execute them, if they are valid.
- SQL Request / Manager : has full access on sql requests.

View File

@@ -1,20 +0,0 @@
This module provides an abstract model to manage SQL Select requests on database.
It is not usefull for itself. You can see an exemple of implementation in the
'sql_export' module. (same repository).
Implemented features
~~~~~~~~~~~~~~~~~~~~
* Add some restrictions in the sql request:
* you can only read datas. No update, deletion or creation are possible.
* some tables are not allowed, because they could contains clear password
or keys. For the time being ('ir_config_parameter').
* The request can be in a 'draft' or a 'SQL Valid' status. To be valid,
the request has to be cleaned, checked and tested. All of this operations
can be disabled in the inherited modules.
* This module two new groups:
* SQL Request / User : Can see all the sql requests by default and execute
them, if they are valid.
* SQL Request / Manager : has full access on sql requests.

View File

@@ -0,0 +1,7 @@
This module add the 'pgsql' mode syntax for the ace widget. (the ace
widget is used in odoo web module, but only with the xml and python
mode).
The file is a copy of the file present here
(<https://github.com/ajaxorg/ace-builds/blob/v1.12.3/src/mode-pgsql.js>
(Release 18 Oct 2022)

View File

@@ -1,7 +0,0 @@
This module add the 'pgsql' mode syntax for the ace widget.
(the ace widget is used in odoo web module, but only with
the xml and python mode).
The file is a copy of the file present here
(https://github.com/ajaxorg/ace-builds/blob/v1.12.3/src/mode-pgsql.js
(Release 18 Oct 2022)

View File

@@ -0,0 +1,16 @@
Inherit the model:
``` python
from odoo import models
class MyModel(models.model)
_name = 'my.model'
_inherit = ['sql.request.mixin']
_sql_request_groups_relation = 'my_model_groups_rel'
_sql_request_users_relation = 'my_model_users_rel'
```
See implementations in the modules `bi_sql_editor` and `sql_export`.
(same OCA/reporting-engine repository)

View File

@@ -1,16 +0,0 @@
Inherit the model:
.. code-block:: python
from odoo import models
class MyModel(models.model)
_name = 'my.model'
_inherit = ['sql.request.mixin']
_sql_request_groups_relation = 'my_model_groups_rel'
_sql_request_users_relation = 'my_model_users_rel'
See implementations in the modules ``bi_sql_editor`` and ``sql_export``. (same OCA/reporting-engine repository)

View File

@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -369,35 +368,28 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e65a56914d10ae27bb307f92fe00fa9c00a67f0842a1227a7a2a869c1847a166
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/16.0/sql_request_abstract"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-sql_request_abstract"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides an abstract model to manage SQL Select requests on database.
It is not usefull for itself. You can see an exemple of implementation in the
sql_export module. (same repository).</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/17.0/sql_request_abstract"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-sql_request_abstract"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides an abstract model to manage SQL Select requests on
database. It is not usefull for itself. You can see an exemple of
implementation in the sql_export module. (same repository).</p>
<div class="section" id="implemented-features">
<h1>Implemented features</h1>
<ul class="simple">
<li><dl class="first docutils">
<dt>Add some restrictions in the sql request:</dt>
<dd><ul class="first last">
<li>you can only read datas. No update, deletion or creation are possible.</li>
<li>some tables are not allowed, because they could contains clear password
or keys. For the time being (ir_config_parameter).</li>
<li>Add some restrictions in the sql request:<ul>
<li>you can only read datas. No update, deletion or creation are
possible.</li>
<li>some tables are not allowed, because they could contains clear
password or keys. For the time being (ir_config_parameter).</li>
</ul>
</dd>
</dl>
</li>
<li>The request can be in a draft or a SQL Valid status. To be valid,
the request has to be cleaned, checked and tested. All of this operations
can be disabled in the inherited modules.</li>
<li><dl class="first docutils">
<dt>This module two new groups:</dt>
<dd><ul class="first last">
<li>SQL Request / User : Can see all the sql requests by default and execute
them, if they are valid.</li>
the request has to be cleaned, checked and tested. All of this
operations can be disabled in the inherited modules.</li>
<li>This module two new groups:<ul>
<li>SQL Request / User : Can see all the sql requests by default and
execute them, if they are valid.</li>
<li>SQL Request / Manager : has full access on sql requests.</li>
</ul>
</dd>
</dl>
</li>
</ul>
<p><strong>Table of contents</strong></p>
@@ -423,13 +415,14 @@ them, if they are valid.</li>
</span> <span class="n">_sql_request_users_relation</span> <span class="o">=</span> <span class="s1">'my_model_users_rel'</span>
</pre>
<p>See implementations in the modules <tt class="docutils literal">bi_sql_editor</tt> and <tt class="docutils literal">sql_export</tt>. (same OCA/reporting-engine repository)</p>
<p>See implementations in the modules <tt class="docutils literal">bi_sql_editor</tt> and <tt class="docutils literal">sql_export</tt>.
(same OCA/reporting-engine repository)</p>
</div>
<div class="section" id="development">
<h2><a class="toc-backref" href="#toc-entry-2">Development</a></h2>
<p>This module add the pgsql mode syntax for the ace widget.
(the ace widget is used in odoo web module, but only with
the xml and python mode).</p>
<p>This module add the pgsql mode syntax for the ace widget. (the ace
widget is used in odoo web module, but only with the xml and python
mode).</p>
<p>The file is a copy of the file present here
(<a class="reference external" href="https://github.com/ajaxorg/ace-builds/blob/v1.12.3/src/mode-pgsql.js">https://github.com/ajaxorg/ace-builds/blob/v1.12.3/src/mode-pgsql.js</a>
(Release 18 Oct 2022)</p>
@@ -439,7 +432,7 @@ the xml and python mode).</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20sql_request_abstract%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20sql_request_abstract%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -460,6 +453,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Sylvain LE GAL (<a class="reference external" href="https://twitter.com/legalsylvain">https://twitter.com/legalsylvain</a>)</li>
<li>Alfadil Tabar (<a class="reference external" href="mailto:alfadil.tabar&#64;gmail.com">alfadil.tabar&#64;gmail.com</a>)</li>
<li>Helly kapatel &lt;<a class="reference external" href="mailto:helly.kapatel&#64;initos.com">helly.kapatel&#64;initos.com</a>&gt;</li>
<li>Nguyen Minh Chien &lt;<a class="reference external" href="mailto:chien&#64;trobz.com">chien&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
@@ -471,7 +465,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/sql_request_abstract">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/17.0/sql_request_abstract">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -0,0 +1,8 @@
/** @odoo-module **/
import {CodeEditor} from "@web/core/code_editor/code_editor";
import {patch} from "@web/core/utils/patch";
patch(CodeEditor, {
MODES: [...CodeEditor.MODES, "pgsql"],
});

View File

@@ -27,7 +27,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<button
name="button_validate_sql_expression"
type="object"
states="draft"
invisible="state != 'draft'"
string="Validate SQL Expression"
class="oe_highlight"
groups="sql_request_abstract.group_sql_request_manager"
@@ -35,14 +35,14 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<button
name="button_set_draft"
type="object"
states="sql_valid"
invisible="state != 'sql_valid'"
string="Set to Draft"
groups="sql_request_abstract.group_sql_request_manager"
/>
<button
name="button_preview_sql_expression"
type="object"
states="draft"
invisible="state != 'draft'"
string="Preview Results"
groups="sql_request_abstract.group_sql_request_manager"
/>
@@ -66,7 +66,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
name="query"
nolabel="1"
colspan="2"
attrs="{'readonly': [('state', '!=', 'draft')]}"
readonly="state != 'draft'"
widget="ace"
options="{'mode': 'pgsql'}"
/>