OdooWiki OCA HUB

SQL Request Abstract

sql_request_abstract folder_open OCA/reporting-engine open_in_new
Tools License: AGPL-3

This module provides an abstract model to manage SQL Select requests on database. It is not usefull for itself. You can see an example 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 adds 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.

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Provides the shared building blocks used by other modules to store, check and safely run read-only SQL queries in Odoo. It adds a SQL Request security category with User and Manager groups and a form where a query can be written, validated and previewed.

This is a technical foundation module: it does not add its own menu, but it defines the screen and rules that modules built on it (such as SQL export tools) reuse.

On the form users get a name, a note, a SQL query editor with PostgreSQL syntax highlighting, and a status bar with Draft and SQL Valid states. Managers see three buttons: Validate SQL Expression, Preview Results and Set to Draft. Validating cleans the query (removes trailing semicolons), refuses forbidden words such as delete, drop, insert, alter, truncate, execute, create, update and ir_config_parameter, then tries to run the query inside a savepoint that is rolled back afterwards. Preview runs the query and shows the first 100 result lines.

A query in Draft cannot be executed. Access can be limited to specific allowed groups and allowed users, and a technical flag records when those groups change. A query can optionally run against an external database, but only if the Odoo configuration file defines one, otherwise a validation error is raised. Materialized views require PostgreSQL 9.3 or later.

Security is handled by two groups, SQL Request / User (read and execute valid requests) and SQL Request / Manager (full create, edit and delete rights). The model inherits mail.thread, so records keep a chatter.

Depends on

mail

Required by other modules

Models and fields (1)
  • sql.request.mixin · new modelname, note, query, state, user_ids (Allowed Users), group_ids (Allowed Groups), has_group_changed, use_external_database

Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 8 confirmed, 1 with no information of 9 versions.

Sources · Odoo 18.0

Confirmed on 2026-11-03 in branch 18.0 of OCA/reporting-engine.

terminal Installation and usage

OCA documentation · Odoo 19.0

To configure the use of an external database, you need to edit the main configuration file of your instance and add the external database configuration with following keys : * external_db_user * external_db_password * external_db_name * external_db_host * external_db_port

Inherit the model:

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)

No verified information in OCA: Installation.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.