Settings & Custom SQL

Updated 13 July 2026

Configure global defaults and build advanced widgets with custom database queries (managers only).

Overview

The Settings screen (under Odoo Settings → Advance Dashboard) lets managers configure global defaults for new dashboards and control whether custom SQL queries are allowed. Custom SQL is an advanced feature that lets managers write database queries to pull data from multiple tables – useful when standard Odoo models cannot answer your question.

How It Works

Global settings apply to all new dashboards created after the setting is saved. Custom SQL widgets run read-only SELECT queries against your Odoo database. The system automatically replaces placeholders like {#MYCOMPANY} and {#DATE_FROM} with real values based on the dashboard’s date filter. Only SELECT queries are allowed – no data can be modified.

Step-by-Step Guide

Settings
Custom SQL Widget

Settings & SQL Fields

Field Explanations

Default Auto-Refresh

Sets the starting auto-refresh value for every new dashboard. Existing dashboards are not affected – change them individually.

Custom SQL (toggle)

When disabled, no one can create or edit SQL widgets. Enable only if you have team members who understand database queries. Regular Odoo Model widgets are unaffected.

Data Source

On each widget, choose “Odoo Model” for standard widgets or “Custom SQL” for advanced database queries. Only managers can use Custom SQL.

SQL Query

A read-only SELECT statement. Must start with SELECT. Cannot contain INSERT, UPDATE, DELETE, or other modifying commands. The system blocks dangerous statements automatically.

{#MYCOMPANY}

Automatically replaced with your current company’s database ID. Use it in WHERE clauses to filter data to your company: WHERE company_id = {#MYCOMPANY}

{#DATE_FROM} / {#DATE_TO}

Replaced with the start and end dates from the dashboard’s active date filter. Ensures SQL widgets respect the same time period as other widgets.

{#UID}

Replaced with the logged-in user’s ID. Useful for “my records” queries: WHERE user_id = {#UID}

{#LANG}

Replaced with the user’s language code (e.g., en_US). Use inside JSON translations: name->>'{#LANG}'

Preview Query

Runs the SQL against your database and shows the first 50 rows. Always preview before saving to catch errors early. Only managers can preview.

Tips

Common Mistakes

Image

Settings & Custom SQL