This module, named "SQL Request Abstract," acts as a foundation for building functionalities related to managing and executing SQL SELECT queries within the Odoo framework. While it doesn't directly serve a purpose on its own, it lays the groundwork for other modules like "bi_sql_editor" and "sql_export" to leverage its capabilities.
This module implements several key features to enhance the management of SQL Select requests in the database:
Firstly, it adds restrictions to the SQL requests, allowing only data reading operations. Updates, deletions, or creations are not permitted to ensure data integrity and security. Additionally, certain tables, such as 'ir_config_parameter', are restricted due to their sensitive nature, as they may contain clear passwords or keys.
Furthermore, SQL requests can exist in either a 'draft' or 'SQL Valid' status. To attain the 'SQL Valid' status, requests must undergo cleaning, checking, and testing processes. These operations can be optionally disabled in inherited modules, providing flexibility in workflow management.
Additionally, this module introduces two new user groups: 'SQL Request / User' and 'SQL Request / Manager'. Users belonging to the 'SQL Request / User' group have default access to view and execute SQL requests, provided they are valid. On the other hand, users in the 'SQL Request / Manager' group have full access rights, enabling them to manage SQL requests comprehensively.
To utilize the functionality ,inherit the model in your custom module. Import the necessary modules and define your model class as shown below.
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'
You can reference the implementations in the modules 'bi_sql_editor' or 'sql_export' for guidance and inspiration. These modules demonstrate practical use cases and implementations of the SQL request functionality provided by this module.
This module acts as a foundation, providing a unified structure for managing various aspects of SQL SELECT queries within Odoo. This simplifies development for other modules that need functionalities related to working with SQL queries, saving time and effort.
To safeguard your data, the module enforces a read-only approach. This means it can only retrieve information from the database, preventing any unintended modifications, deletions, or creation of data. This helps maintain data integrity and prevents potential security risks.
Before executing a SQL request, the module puts it through a multi-stage validation process. This includes cleaning the query syntax, checking its functionality, and testing it to ensure accuracy and security. This validation process helps catch errors and prevent unintended consequences before the query interacts with your data.
The module implements access control through two
user groups:
SQL Request / User: View and execute valid SQL
requests for data retrieval.
SQL Request / Manager: Full access to manage all
functionalities and user permissions.