FAQ and Troubleshooting
Common questions, troubleshooting steps, and technical reference for the SDLC PSQL Query Execute module.
Frequently Asked Questions
Can I run INSERT, UPDATE, or DELETE queries?
No. The module only allows SELECT queries. All other SQL operations are blocked by a built-in safety guard. If you attempt a non-SELECT query, you will receive a validation error: "Only SELECT queries are allowed for safety reasons."
Who can access this module?
Only users with the Settings / System Administrator role (base.group_system) can access the module. Regular users will not see the menu item or be able to access query records.
Do I need Developer Mode enabled?
Yes. The PSQL Query menu is located under Settings > Technical, which is only visible when Developer Mode is activated. Go to Settings > General Settings > Developer Tools > Activate Developer Mode.
Why is my XLSX export not working?
The XLSX export feature requires the xlsxwriter Python library. Install it with:
pip install xlsxwriter
Without this library, query execution and result display will work normally, but the XLSX button will not function.
Can I use JOINs, subqueries, and other complex SQL?
Yes. Any valid PostgreSQL SELECT statement is supported, including JOINs, subqueries, CTEs (WITH clauses), aggregate functions, window functions, and more. The only restriction is that the query must begin with SELECT.
Is there a limit on result size?
There is no hard limit on the number of rows returned. However, very large result sets may be slow to render in the browser. The result container scrolls vertically at a maximum height of 500px. It is recommended to use LIMIT in your queries.
What happens to NULL values?
NULL values are automatically displayed as the string None in both the HTML result table and the XLSX export.
Troubleshooting
"Please enter a SQL query."
Cause: The query field is empty or contains only whitespace.
Solution: Enter a valid SELECT statement in the query field before clicking Execute/Refresh.
"Only SELECT queries are allowed for safety reasons."
Cause: The query does not start with SELECT (after stripping whitespace).
Solution: Ensure your query begins with SELECT. Remove any leading comments or statements before the SELECT keyword.
"Query execution error: relation does not exist"
Cause: The table name specified in the query does not exist in the database.
Solution: Verify the table name. You can find all available table names by running:
SELECT tablename FROM pg_tables WHERE schemaname = 'public' ORDER BY tablename;
"Query execution error: column does not exist"
Cause: A column name specified in the query does not exist in the referenced table.
Solution: Check the column names for the table by running:
SELECT column_name FROM information_schema.columns
WHERE table_name = 'your_table_name'
ORDER BY ordinal_position;
XLSX button returns a 404 error
Cause: The query record was not found, or no results have been generated yet (column_names is empty).
Solution: Execute the query first using the Execute/Refresh button, then click XLSX.
Menu item not visible
Cause: Developer Mode is not enabled, or the current user does not have System Administrator access.
Solution:
- Enable Developer Mode: Settings > General Settings > Developer Tools > Activate Developer Mode
- Ensure your user has the Settings / System Administrator role
Data Model Reference
psql.query
Main and only model in the module. Inherits from mail.thread and mail.activity.mixin.
| Field | Type | Properties | Description |
|---|---|---|---|
name | Char | required, tracking=True | Query name / label for identifying saved queries |
query | Text | -- | The SQL SELECT statement to execute |
result | Html | readonly | Rendered HTML table of query results |
column_names | Text | readonly | JSON-encoded list of column header names |
row_data | Text | readonly | JSON-encoded list of data row arrays |
Methods
action_execute_query(self)
Executes the SQL query and populates the result, column_names, and row_data fields.
| Aspect | Detail |
|---|---|
| Trigger | Execute/Refresh button (type="object") |
| Multi-record | Yes -- iterates with for rec in self |
| Validation | Checks for empty query and non-SELECT statements |
| Execution | self.env.cr.execute(query) -- direct cursor access |
| Column extraction | [desc[0] for desc in self.env.cr.description] |
| Data fetch | self.env.cr.fetchall() |
| Error handling | try/except Exception -> ValidationError |
action_download_xlsx(self)
Triggers the XLSX file download via a URL action.
| Aspect | Detail |
|---|---|
| Trigger | XLSX button (type="object") |
| Multi-record | No -- uses ensure_one() |
| Validation | Checks that column_names and row_data are not empty |
| Return | ir.actions.act_url pointing to /psql_query/download_xlsx/<id>, target: new tab |
Controller API
| Property | Value |
|---|---|
| URL Pattern | /psql_query/download_xlsx/<int:record_id> |
| HTTP Method | GET |
| Authentication | auth='user' -- requires authenticated Odoo session |
| Response Type | File download (binary XLSX) |
| Content-Type | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
Support
| Channel | Details |
|---|---|
| Website | sdlccorp.com |
| Contact | sdlccorp.com/contact-us |
| sales@sdlccorp.com | |
| Module Name | sdlc_psql_query_execute |
| License | LGPL-3 |
Contact SDLC Corp at sdlccorp.com/contact-us or email sales@sdlccorp.com