Odoo SQL from plain English
Generate schema-aware PostgreSQL for your Odoo database. It maps your custom fields, fixes its own syntax errors, and stays read-only by default, then shows you the query before anything runs. Free, with source code.
SELECT p.name,
SUM(l.price_total) AS revenue
FROM sale_order_line l
JOIN sale_order o ON o.id = l.order_id
JOIN res_partner p ON p.id = o.partner_id
WHERE o.state = 'sale'
AND o.date_order >= date_trunc('year', now())
GROUP BY p.name
ORDER BY revenue DESC
LIMIT 5;Schema-aware · review before you run
Built for real Odoo databases
Context-aware generation
It knows your database
Generic AI tools guess table names. This module inspects your instance's ir.model and ir.model.fields, so it knows your custom Studio fields, third-party modules, and relation types.
- Handles LEFT JOIN vs INNER JOIN from the Odoo ORM definitions.
- Maps Customer Name to res_partner.name without hallucinating.
- Writes SQL compatible with your PostgreSQL version.
Self-healing loop
Automatic error correction
Even senior devs make syntax errors. If a query fails, the module captures the PostgreSQL error, feeds it back to the AI, and generates a corrected query instantly.
- Detects "column does not exist" and ambiguous-column errors.
- Adapts to database constraints on the fly.
- Shows the error history and the final successful query.
Developer scaffolding
Prototype faster
Frame complex logic in natural language, then paste optimized SQL into your Python (self.env.cr.execute(...)) or Odoo reports.
- Clean, formatted SQL ready for your IDE.
- Handles sub-queries, GROUP BY, and HAVING clauses.
- Suggests indexed columns for faster retrieval.
Safety protocols
Execution guardrails
Running raw SQL on production is risky. Strict safety checks keep the AI from breaking your database.
- SELECT-only by default; UPDATE, DELETE, and DROP are restricted.
- Queries run in a safe transaction block to prevent locks.
- Restrict access to specific user groups.
Where teams use it
Reporting
Describe a join like "sale.order.line with product.template, total weight" and get optimized SQL to paste into a QWeb report or module.
Data migration
Validate data on the fly: "partners without an email created after 2023" returns SQL instead of a throwaway script.
Support
Dig into raw tables to explain a wrong number, generating the query from a plain-English question.
Technical fit
Compatibility
Odoo v16, v17, v18, v19 (Community & Enterprise).
Database
PostgreSQL 12+.
LLM integration
OpenAI (bring your own key): GPT-4o, GPT-4o-mini.
Privacy
Schema metadata and prompt only. No row data sent for training.
Interface
Built with the Odoo Web Library (OWL). Responsive and fast.
Export
CSV / Excel export of query results.
Need help choosing, or a custom setup? Talk to us or book a call.
Free download with full source code. See the rest of the catalogue.
AI SQL Generator questions
What is the Niyu AI SQL Generator for Odoo?+
It is a free Odoo developer tool that turns plain-English questions into schema-aware PostgreSQL for your Odoo database, with safety guardrails and the generated SQL shown for review.
Does it understand my Odoo schema?+
Yes. It maps your tables and fields, including custom Studio fields and relational fields, so the generated SQL references real columns rather than guesses.
Is it free?+
Yes. The AI SQL Generator is a free utility with source code included. Download it after a quick email-gated step.
Is it safe to run the generated SQL?+
The tool generates SQL with guardrails and shows it to you before anything runs, so a developer can review the query before executing it on a database.
