Odoo Code Review
Objective
Review Odoo code changes against clear criteria, identify risks, and score using a weighted scale from an Odoo-expert perspective — using the reference pack that matches the target Odoo version.
Resolve the target Odoo version
Before reviewing, resolve ODOO_VERSION (one of 16.0, 17.0, 18.0, 19.0) in this order. Stop at the first one that succeeds:
- Explicit argument passed to the agent invocation (e.g.
odoo_version: "19.0").
- Project config, in this order:
.odoo-version file at the repo root (contents: e.g. 19.0).
odoo_version key in .claude/odoo.json.
odoo.version key in package.json or tool.odoo.version in pyproject.toml.
- Manifest heuristic — scan workspace
__manifest__.py files for the 'version' key. Use the dominant major version (e.g. 18.0.1.0.0 → 18.0).
- Fallback — default to
19.0 (latest supported) and note the assumption in the review output so the user can correct it.
Derive ODOO_MAJOR from ODOO_VERSION by stripping .0 (e.g. 18.0 → 18). All guide paths below use these placeholders.
Supported versions: 16.0, 17.0, 18.0, 19.0. If resolution yields anything else, stop and tell the user the version is out of scope.
Pre-review Requirements
- Read
skills/odoo-${ODOO_VERSION}/SKILL.md as the master index for the resolved version's guides.
- Read
skills/odoo-${ODOO_VERSION}/references/api-highlights.md for the version-distinguishing rules (what changed, what to flag, what's allowed).
- Read relevant guides from
skills/odoo-${ODOO_VERSION}/references/ based on change scope:
- Models/ORM:
odoo-${ODOO_MAJOR}-model-guide.md
- Fields:
odoo-${ODOO_MAJOR}-field-guide.md
- Decorators:
odoo-${ODOO_MAJOR}-decorator-guide.md
- Performance:
odoo-${ODOO_MAJOR}-performance-guide.md
- Views/XML:
odoo-${ODOO_MAJOR}-view-guide.md
- Security:
odoo-${ODOO_MAJOR}-security-guide.md
- Controllers:
odoo-${ODOO_MAJOR}-controller-guide.md
- Transactions:
odoo-${ODOO_MAJOR}-transaction-guide.md
- Mixins:
odoo-${ODOO_MAJOR}-mixins-guide.md (mail.thread, activities)
- Testing:
odoo-${ODOO_MAJOR}-testing-guide.md
- Migration:
odoo-${ODOO_MAJOR}-migration-guide.md
- Actions:
odoo-${ODOO_MAJOR}-actions-guide.md
- Data Files:
odoo-${ODOO_MAJOR}-data-guide.md
- Manifest:
odoo-${ODOO_MAJOR}-manifest-guide.md
- Identify scope: module, file, and change context.
- Apply the version-distinguishing rules from
api-highlights.md (e.g. <tree> vs <list>, group_operator= vs aggregator=, optional _name in v19, etc.).
Expert Review Process
- Scope: Identify change scope, objectives, and key risks
- ORM & Model Methods: Search patterns, CRUD operations, recordset operations
- Field Definitions: Field types, computed fields, relational field parameters
- API Decorators:
@api.depends, @api.constrains, @api.ondelete, @api.model_create_multi
- Performance: N+1 detection, batch operations, field selection
- Transaction Management: Savepoints,
UniqueViolation, serialization
- Views & XML: Version-appropriate list tag, inheritance, structure (see
api-highlights.md)
- Security: ACL, record rules, exceptions,
sudo() usage
- Controllers: Auth types, CSRF protection, routing
- Mixins:
mail.thread, mail.activity.mixin, mail.alias.mixin usage
- Testing: Test coverage, proper test cases,
@tagged decorators
- Migration: Migration scripts, data migration patterns
- Actions: Window actions, server actions, cron jobs
- Data Files: XML/CSV data structure,
noupdate, shortcuts
- Manifest: Dependencies, external deps, hooks, assets
Complete Checklist
Rules below are version-neutral unless they reference api-highlights.md. Always combine this checklist with the version-specific highlights for the resolved ODOO_VERSION.
ORM & Model Methods (30%)
- ❌ DO NOT use
search() inside a loop (N+1 anti-pattern)
- ✅ Use
search_read() when dict output needed
- ✅ Use
read_group() for aggregate queries
- ✅ Use
IN domain instead of search in loop: [('order_id', 'in', orders.ids)]
- ✅ Batch
create([{...}, {...}]) for multiple records
- ✅ Use
recordset.write() instead of loop
- ✅ Use
recordset.unlink() instead of loop
- ✅
@api.model_create_multi on create() overrides (see api-highlights.md for version-specific enforcement)
Views & XML (15%)
- Use the list tag appropriate to
ODOO_VERSION (see api-highlights.md: <tree> in 16/17, <list> in 18+).
- Use the attrs syntax appropriate to
ODOO_VERSION: legacy attrs= / states= are valid in 16, but rejected in 17+ where direct expressions are required.
- Inheritance via
xpath / position — the nested list tag must match the version.
- Avoid duplicate
name= attributes in records.
Fields (15%)
Monetary with currency_field
Many2one with ondelete
- Computed field with
store=True if filtered/searched
- Aggregation parameter:
group_operator= (v16/17) vs aggregator= (v18+) — see api-highlights.md.
Decorators (10%)
@api.depends with complete dotted paths
@api.constrains for invariants
@api.ondelete(at_uninstall=False) instead of overriding unlink() for validation
@api.model_create_multi for batch create
Performance (10%)
- Avoid N+1 in loops
- Prefer
read_group() / search_read() over per-record fetches
- Use
prefetch_fields thoughtfully
Transactions (5%)
savepoint around recoverable failures
- Handle
UniqueViolation explicitly
- Advisory locks for cross-record serialization
Security (5%)
- Specific exceptions:
UserError, ValidationError, AccessError
- No bare
except Exception
sudo() used narrowly with justification
Controllers (3%)
- Correct
auth= (user, public, none)
csrf=False only with justification
type='json' vs type='http' matches the client
Mixins (3%)
mail.thread with proper tracking fields
mail.activity.mixin for activities
mail.alias.mixin with alias fields
Testing (2%)
- Regression test for each reproducible bug fix
- Tests for new functionality and important error paths
- Security-sensitive flows tested with the lowest practical permissions
- No state leakage between
subTest cases; records use the active environment
- Deterministic dates and fixtures; no unnecessary reliance on demo data
- External services mocked by default, with live integrations explicitly tagged
- Coverage drops investigated for missing meaningful cases
- Proper use of
@tagged
- Query count assertions for hot paths
Manifest & Data (2%)
- All dependencies declared
- External deps listed
- Hooks wired correctly
noupdate="1" for reference data
Scoring
Weight each section per the percentages above. Total out of 100. Report:
- Score per section with brief justification.
- Blocking issues (must fix before merge).
- Non-blocking suggestions.
- Explicitly name the resolved
ODOO_VERSION at the top of the report.
Deep Dive Checks
When reviewing, thoroughly check (references below use ${ODOO_MAJOR} — substitute the resolved value):
Does @api.depends have complete dependencies?
- Check dotted paths:
partner_id.email instead of just partner_id
- Missing dependencies cause N queries
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-decorator-guide.md
Are there N+1 queries?
- Loop with
search(), browse(), read() inside
- Solution:
search_read() with IN domain or read_group()
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-performance-guide.md
Are there batch operations?
create(), write(), unlink() in loop
- Solution: batch operations on recordset
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-performance-guide.md
Is transaction safe?
UniqueViolation handling without savepoint
- Concurrent updates without advisory lock
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-transaction-guide.md
Are version-specific patterns correct?
- List tag, attrs syntax, aggregation parameter, optional
_name (v19).
- Reference:
skills/odoo-${ODOO_VERSION}/references/api-highlights.md + odoo-${ODOO_MAJOR}-view-guide.md
Are field definitions correct?
Monetary with currency_field
Many2one with ondelete
- Computed field with
store=True if needed
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-field-guide.md
Is exception handling correct?
UserError, ValidationError, AccessError
- No generic
Exception
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-security-guide.md
Are mixins properly configured?
mail.thread with proper tracking fields
mail.activity.mixin for activities
mail.alias.mixin with alias fields
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-mixins-guide.md
Is testing adequate?
- Regression test for each reproducible bug fix
- Tests for new functionality and important error paths
- Security-sensitive flows use the lowest practical permissions
- No state leakage between
subTest cases or stored record environments
- Deterministic dates and fixtures; no unnecessary demo-data dependency
- External services mocked by default and live integrations explicitly tagged
- Coverage drops investigated for missing meaningful cases
- Proper use of
@tagged decorators
- Query count assertions for performance
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-testing-guide.md
Are migrations handled correctly?
- Proper migration script location
- Pre/post migration scripts
- Idempotent operations
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-migration-guide.md
Are actions properly defined?
- Window actions with correct context
- Server actions for automation
- Cron jobs with proper intervals
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-actions-guide.md
Are data files correct?
- Proper XML record structure
noupdate="1" for reference data
- CSV data properly formatted
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-data-guide.md
Is manifest correct?
- All dependencies declared
- External dependencies listed
- Hooks properly configured
- Reference:
skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-manifest-guide.md
1---
2name: odoo-code-review
3description: Review Odoo code for correctness, security, performance, and version-specific standards (Odoo 16, 17, 18, or 19). Use when reviewing Odoo modules, diffs, or pull requests; produce a scored report with weighted criteria.
4metadata:
5 source: https://skillmd.com/skills/unclecatvn/odoo-code-review
6---
7
8# Odoo Code Review
9
10## Objective
11
12Review Odoo code changes against clear criteria, identify risks, and score using a weighted scale from an Odoo-expert perspective — using the reference pack that matches the target Odoo version.
13
14## Resolve the target Odoo version
15
16Before reviewing, resolve `ODOO_VERSION` (one of `16.0`, `17.0`, `18.0`, `19.0`) in this order. Stop at the first one that succeeds:
17
181. **Explicit argument** passed to the agent invocation (e.g. `odoo_version: "19.0"`).
192. **Project config**, in this order:
20 - `.odoo-version` file at the repo root (contents: e.g. `19.0`).
21 - `odoo_version` key in `.claude/odoo.json`.
22 - `odoo.version` key in `package.json` or `tool.odoo.version` in `pyproject.toml`.
233. **Manifest heuristic** — scan workspace `__manifest__.py` files for the `'version'` key. Use the dominant major version (e.g. `18.0.1.0.0` → `18.0`).
244. **Fallback** — default to `19.0` (latest supported) and note the assumption in the review output so the user can correct it.
25
26Derive `ODOO_MAJOR` from `ODOO_VERSION` by stripping `.0` (e.g. `18.0` → `18`). All guide paths below use these placeholders.
27
28Supported versions: **16.0, 17.0, 18.0, 19.0**. If resolution yields anything else, stop and tell the user the version is out of scope.
29
30## Pre-review Requirements
31
32- Read `skills/odoo-${ODOO_VERSION}/SKILL.md` as the master index for the resolved version's guides.
33- Read `skills/odoo-${ODOO_VERSION}/references/api-highlights.md` for the version-distinguishing rules (what changed, what to flag, what's allowed).
34- Read relevant guides from `skills/odoo-${ODOO_VERSION}/references/` based on change scope:
35 - **Models/ORM**: `odoo-${ODOO_MAJOR}-model-guide.md`
36 - **Fields**: `odoo-${ODOO_MAJOR}-field-guide.md`
37 - **Decorators**: `odoo-${ODOO_MAJOR}-decorator-guide.md`
38 - **Performance**: `odoo-${ODOO_MAJOR}-performance-guide.md`
39 - **Views/XML**: `odoo-${ODOO_MAJOR}-view-guide.md`
40 - **Security**: `odoo-${ODOO_MAJOR}-security-guide.md`
41 - **Controllers**: `odoo-${ODOO_MAJOR}-controller-guide.md`
42 - **Transactions**: `odoo-${ODOO_MAJOR}-transaction-guide.md`
43 - **Mixins**: `odoo-${ODOO_MAJOR}-mixins-guide.md` (mail.thread, activities)
44 - **Testing**: `odoo-${ODOO_MAJOR}-testing-guide.md`
45 - **Migration**: `odoo-${ODOO_MAJOR}-migration-guide.md`
46 - **Actions**: `odoo-${ODOO_MAJOR}-actions-guide.md`
47 - **Data Files**: `odoo-${ODOO_MAJOR}-data-guide.md`
48 - **Manifest**: `odoo-${ODOO_MAJOR}-manifest-guide.md`
49- Identify scope: module, file, and change context.
50- Apply the version-distinguishing rules from `api-highlights.md` (e.g. `<tree>` vs `<list>`, `group_operator=` vs `aggregator=`, optional `_name` in v19, etc.).
51
52## Expert Review Process
53
541. **Scope**: Identify change scope, objectives, and key risks
552. **ORM & Model Methods**: Search patterns, CRUD operations, recordset operations
563. **Field Definitions**: Field types, computed fields, relational field parameters
574. **API Decorators**: `@api.depends`, `@api.constrains`, `@api.ondelete`, `@api.model_create_multi`
585. **Performance**: N+1 detection, batch operations, field selection
596. **Transaction Management**: Savepoints, `UniqueViolation`, serialization
607. **Views & XML**: Version-appropriate list tag, inheritance, structure (see `api-highlights.md`)
618. **Security**: ACL, record rules, exceptions, `sudo()` usage
629. **Controllers**: Auth types, CSRF protection, routing
6310. **Mixins**: `mail.thread`, `mail.activity.mixin`, `mail.alias.mixin` usage
6411. **Testing**: Test coverage, proper test cases, `@tagged` decorators
6512. **Migration**: Migration scripts, data migration patterns
6613. **Actions**: Window actions, server actions, cron jobs
6714. **Data Files**: XML/CSV data structure, `noupdate`, shortcuts
6815. **Manifest**: Dependencies, external deps, hooks, assets
69
70## Complete Checklist
71
72Rules below are version-neutral unless they reference `api-highlights.md`. Always combine this checklist with the version-specific highlights for the resolved `ODOO_VERSION`.
73
74### ORM & Model Methods (30%)
75- ❌ **DO NOT** use `search()` inside a loop (N+1 anti-pattern)
76- ✅ Use `search_read()` when dict output needed
77- ✅ Use `read_group()` for aggregate queries
78- ✅ Use `IN` domain instead of search in loop: `[('order_id', 'in', orders.ids)]`
79- ✅ Batch `create([{...}, {...}])` for multiple records
80- ✅ Use `recordset.write()` instead of loop
81- ✅ Use `recordset.unlink()` instead of loop
82- ✅ `@api.model_create_multi` on `create()` overrides (see `api-highlights.md` for version-specific enforcement)
83
84### Views & XML (15%)
85- Use the list tag appropriate to `ODOO_VERSION` (see `api-highlights.md`: `<tree>` in 16/17, `<list>` in 18+).
86- Use the attrs syntax appropriate to `ODOO_VERSION`: legacy `attrs=` / `states=` are valid in 16, but rejected in 17+ where direct expressions are required.
87- Inheritance via `xpath` / `position` — the nested list tag must match the version.
88- Avoid duplicate `name=` attributes in records.
89
90### Fields (15%)
91- `Monetary` with `currency_field`
92- `Many2one` with `ondelete`
93- Computed field with `store=True` if filtered/searched
94- Aggregation parameter: `group_operator=` (v16/17) vs `aggregator=` (v18+) — see `api-highlights.md`.
95
96### Decorators (10%)
97- `@api.depends` with complete dotted paths
98- `@api.constrains` for invariants
99- `@api.ondelete(at_uninstall=False)` instead of overriding `unlink()` for validation
100- `@api.model_create_multi` for batch create
101
102### Performance (10%)
103- Avoid N+1 in loops
104- Prefer `read_group()` / `search_read()` over per-record fetches
105- Use `prefetch_fields` thoughtfully
106
107### Transactions (5%)
108- `savepoint` around recoverable failures
109- Handle `UniqueViolation` explicitly
110- Advisory locks for cross-record serialization
111
112### Security (5%)
113- Specific exceptions: `UserError`, `ValidationError`, `AccessError`
114- No bare `except Exception`
115- `sudo()` used narrowly with justification
116
117### Controllers (3%)
118- Correct `auth=` (`user`, `public`, `none`)
119- `csrf=False` only with justification
120- `type='json'` vs `type='http'` matches the client
121
122### Mixins (3%)
123- `mail.thread` with proper tracking fields
124- `mail.activity.mixin` for activities
125- `mail.alias.mixin` with alias fields
126
127### Testing (2%)
128- Regression test for each reproducible bug fix
129- Tests for new functionality and important error paths
130- Security-sensitive flows tested with the lowest practical permissions
131- No state leakage between `subTest` cases; records use the active environment
132- Deterministic dates and fixtures; no unnecessary reliance on demo data
133- External services mocked by default, with live integrations explicitly tagged
134- Coverage drops investigated for missing meaningful cases
135- Proper use of `@tagged`
136- Query count assertions for hot paths
137
138### Manifest & Data (2%)
139- All dependencies declared
140- External deps listed
141- Hooks wired correctly
142- `noupdate="1"` for reference data
143
144## Scoring
145
146Weight each section per the percentages above. Total out of 100. Report:
147- Score per section with brief justification.
148- Blocking issues (must fix before merge).
149- Non-blocking suggestions.
150- Explicitly name the resolved `ODOO_VERSION` at the top of the report.
151
152## Deep Dive Checks
153
154When reviewing, thoroughly check (references below use `${ODOO_MAJOR}` — substitute the resolved value):
155
1561. **Does `@api.depends` have complete dependencies?**
157 - Check dotted paths: `partner_id.email` instead of just `partner_id`
158 - Missing dependencies cause N queries
159 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-decorator-guide.md`
160
1612. **Are there N+1 queries?**
162 - Loop with `search()`, `browse()`, `read()` inside
163 - Solution: `search_read()` with `IN` domain or `read_group()`
164 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-performance-guide.md`
165
1663. **Are there batch operations?**
167 - `create()`, `write()`, `unlink()` in loop
168 - Solution: batch operations on recordset
169 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-performance-guide.md`
170
1714. **Is transaction safe?**
172 - `UniqueViolation` handling without savepoint
173 - Concurrent updates without advisory lock
174 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-transaction-guide.md`
175
1765. **Are version-specific patterns correct?**
177 - List tag, attrs syntax, aggregation parameter, optional `_name` (v19).
178 - Reference: `skills/odoo-${ODOO_VERSION}/references/api-highlights.md` + `odoo-${ODOO_MAJOR}-view-guide.md`
179
1806. **Are field definitions correct?**
181 - `Monetary` with `currency_field`
182 - `Many2one` with `ondelete`
183 - Computed field with `store=True` if needed
184 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-field-guide.md`
185
1867. **Is exception handling correct?**
187 - `UserError`, `ValidationError`, `AccessError`
188 - No generic `Exception`
189 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-security-guide.md`
190
1918. **Are mixins properly configured?**
192 - `mail.thread` with proper tracking fields
193 - `mail.activity.mixin` for activities
194 - `mail.alias.mixin` with alias fields
195 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-mixins-guide.md`
196
1979. **Is testing adequate?**
198 - Regression test for each reproducible bug fix
199 - Tests for new functionality and important error paths
200 - Security-sensitive flows use the lowest practical permissions
201 - No state leakage between `subTest` cases or stored record environments
202 - Deterministic dates and fixtures; no unnecessary demo-data dependency
203 - External services mocked by default and live integrations explicitly tagged
204 - Coverage drops investigated for missing meaningful cases
205 - Proper use of `@tagged` decorators
206 - Query count assertions for performance
207 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-testing-guide.md`
208
20910. **Are migrations handled correctly?**
210 - Proper migration script location
211 - Pre/post migration scripts
212 - Idempotent operations
213 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-migration-guide.md`
214
21511. **Are actions properly defined?**
216 - Window actions with correct context
217 - Server actions for automation
218 - Cron jobs with proper intervals
219 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-actions-guide.md`
220
22112. **Are data files correct?**
222 - Proper XML record structure
223 - `noupdate="1"` for reference data
224 - CSV data properly formatted
225 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-data-guide.md`
226
22713. **Is manifest correct?**
228 - All dependencies declared
229 - External dependencies listed
230 - Hooks properly configured
231 - Reference: `skills/odoo-${ODOO_VERSION}/references/odoo-${ODOO_MAJOR}-manifest-guide.md`