▲ 3 r/Odoo
Hey everyone,
I’ve been working on integrating LLMs deeply into Odoo (not just a text chatbot, but an agent that can navigate the UI and execute logic). I quickly ran into a massive wall: LLM reasoning loops take 15-30+ seconds, which constantly triggered Odoo's limit-time-real and completely froze the WSGI server.
I wanted to share the asynchronous architecture I built to bypass this and get your thoughts on it.
Here is how I structured it to avoid destroying Odoo's performance:
- Decoupling the AI: I moved the entire LLM orchestrator (Pydantic AI) to an external FastAPI microservice. Odoo now acts simply as a "Headless ERP" and UI provider.
- The "Hybrid Wait" Pattern: Instead of holding the HTTP connection, Odoo launches a background thread for the AI request and waits a maximum of 10 seconds. If the AI takes longer, Odoo frees up the main thread and the OWL frontend switches to polling (every 3 seconds).
- Asynchronous UI Navigation: Since the AI is external, if it decides to "open a view" for the user, it sends a payload to an Odoo webhook. Odoo saves this dictionary (like
ir.actions.act_window) in apending_actiondatabase field. The OWL frontend detects it via polling and executes it without freezing. - Strict ACL Enforcement: Security was a nightmare. To avoid giving the AI "god mode", the FastAPI orchestrator sends the
odoo_user_idto the webhook. Odoo then executessudo().with_user(target_user_id)before running any tool. If the user lacks permissions, the native tool fails safely. - Taming LLM Hallucinations: LLMs kept inventing positional arguments for Odoo models. I had to rewrite the AI-facing methods in Odoo to rely heavily on
kwargsto tolerate these hallucinations without throwing PythonTypeErrorexceptions.
This approach allowed me to integrate pgvector and handle complex reasoning without Odoo even breaking a sweat.
u/AreaRight6029 — 18 days ago