The Challenge: Odoo Is Not a Standard Database
An AI agent cannot operate inside Odoo by treating it as a generic database with SQL queries. Odoo's ORM is a sophisticated abstraction layer with computed fields, onchange triggers, record rules, multi-company isolation, mail thread integration, and a unique security model. An AI agent that ignores these layers will create inconsistent data, bypass security, and break business logic. Understanding the ORM is not optional — it is the foundation of everything an AI agent does inside Odoo.
What the AI Needs to Learn
1. Model Relationships
# AI maps the entire model graph:
"Odoo Model Map — sale.order
Inherits:
mail.thread (message tracking)
mail.activity.mixin (scheduled activities)
portal.mixin (portal access)
Key relationships:
partner_id → res.partner (Many2one, customer)
order_line → sale.order.line (One2many, line items)
company_id → res.company (Many2one, multi-company)
pricelist_id → product.pricelist (Many2one)
team_id → crm.team (Many2one, sales team)
invoice_ids → account.move (Many2many, invoices)
Downstream effects of creating a sale.order:
1. Confirming → creates stock.picking (delivery)
2. Delivering → creates account.move (invoice)
3. Invoice paid → updates payment status
4. Chatter → logs all state changes
5. Activities → creates follow-up tasks
The AI must follow this chain, not shortcut it.
Creating an invoice directly (bypassing SO → DO → Invoice)
breaks inventory tracking and revenue recognition."2. Field Types and Behavior
# AI understands field semantics:
"Field Type Intelligence:
Computed fields (store=True):
amount_total on sale.order
Depends on: order_line.price_subtotal
Behavior: auto-recomputed when lines change
AI rule: NEVER write directly to computed fields
Computed fields (store=False):
display_name on res.partner
Recomputed on every read
AI rule: do not cache, always read fresh
Related fields:
partner_shipping_id.city → delivery city
Follows the relation chain automatically
AI rule: write to the source, not the related field
Selection fields:
state on sale.order: draft, sent, sale, done, cancel
AI rule: use write() to change state, not direct SQL
State changes trigger automations and mail messages
Monetary fields:
price_unit, amount_total — currency-aware
AI rule: always consider currency_id context
Never compare monetary values across currencies directly"3. Security Model
# AI respects Odoo's security layers:
"Security Layers the AI Must Respect:
Layer 1: ir.model.access (CRUD per model per group)
Can this user read sale.order? Check access rights.
AI must call check_access_rights() before operations.
Layer 2: ir.rule (record-level filtering)
Which sale.orders can this user see?
Record rules filter by company, team, ownership.
AI must use search() with proper user context,
NOT sudo().search() which bypasses rules.
Layer 3: Field-level access
Some fields restricted to specific groups.
AI checks field access before reading/writing.
Layer 4: Multi-company isolation
Records belong to companies.
AI operates within the user's allowed companies.
Critical rule: NEVER use sudo() unless absolutely
necessary, and document why."Compute Chains and Side Effects
| Action | Direct Effect | Side Effects |
|---|---|---|
| Add SO line | Line created | Recomputes amount_total, tax_totals |
| Confirm SO | State → sale | Creates delivery, triggers automations |
| Validate delivery | Picking done | Updates stock, creates invoice if auto |
| Post invoice | Move posted | Creates journal items, updates partner balance |
| Register payment | Payment created | Reconciles invoice, updates payment state |
4. The env Object
# AI understands Odoo's Environment:
"The env object carries context for every operation:
env.user — current user (determines permissions)
env.company — current company context
env.context — dictionary with additional context:
lang: 'en_US' (affects translations)
tz: 'US/Eastern' (affects date computations)
active_id: current record in UI
tracking_disable: True (skip mail tracking)
AI must preserve context appropriately:
- Use with_context() to add context, don't replace
- Use with_company() for multi-company operations
- Use with_user() carefully (changes permissions)
- NEVER modify env.context directly"Learning Through Introspection
One of the most powerful capabilities of an AI agent inside Odoo is self-discovery. The agent can introspect the ORM to learn about models it has never seen before — reading ir.model, ir.model.fields, and ir.model.access to understand what exists, what fields are available, what relationships connect models, and who has access to what. This means the agent adapts to custom modules without being explicitly programmed for them.
Common Mistakes AI Agents Make
- Writing directly to computed fields instead of modifying source data
- Using raw SQL instead of ORM methods (bypassing security and triggers)
- Ignoring multi-company context in search queries
- Creating records without proper defaults (env context not set)
- Calling unlink() without checking dependencies (cascade deletes)
- Bypassing workflow state machines (draft → done without intermediate steps)
DeployMonkey AI ORM Intelligence
DeployMonkey's AI agent is built with deep understanding of Odoo's ORM. It respects security layers, follows compute chains, preserves context, and uses proper ORM methods instead of shortcuts. This ORM intelligence is what separates a capable AI agent from one that creates data chaos.