Claude-skill-registry odoo-code-review
Review Odoo code for correctness, security, performance, and Odoo 18 standards. Use when reviewing Odoo modules, diffs, or pull requests; produce a scored report with weighted criteria.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/odoo-code-review" ~/.claude/skills/majiayu000-claude-skill-registry-odoo-code-review && rm -rf "$T"
skills/data/odoo-code-review/SKILL.md- uses sudo
- references .env files
Odoo Code Review
Objective
Review Odoo code changes against clear criteria, identify risks, and score using a weighted scale from an Odoo 18 expert perspective.
Pre-review Requirements
- Read
as the master index for all Odoo 18 guides.skills/odoo/18.0/SKILL.md - Read relevant guides from
based on change scope:skills/odoo/18.0/dev/- Models/ORM:
odoo-18-model-guide.md - Fields:
odoo-18-field-guide.md - Decorators:
odoo-18-decorator-guide.md - Performance:
odoo-18-performance-guide.md - Views/XML:
odoo-18-view-guide.md - Security:
odoo-18-security-guide.md - Controllers:
odoo-18-controller-guide.md - Transactions:
odoo-18-transaction-guide.md - Mixins:
(mail.thread, activities)odoo-18-mixins-guide.md - Testing:
odoo-18-testing-guide.md - Migration:
odoo-18-migration-guide.md - Actions:
odoo-18-actions-guide.md - Data Files:
odoo-18-data-guide.md - Manifest:
odoo-18-manifest-guide.md
- Models/ORM:
- Identify scope: module, file, and change context.
- Master Odoo 18 API changes:
instead of<list>
,<tree>
, etc.@api.ondelete
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 (Odoo 18!)
- Performance: N+1 detection, batch operations, field selection
- Transaction Management: Savepoints, UniqueViolation, serialization
- Views & XML: Odoo 18 tags (
), inheritance, structure<list> - 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
Odoo 18 Complete Checklist
ORM & Model Methods (30%)
- ❌ DO NOT use
inside loop (N+1 anti-pattern)search() - ✅ Use
when dict output neededsearch_read() - ✅ Use
for aggregate queriesread_group() - ✅ Use
domain instead of search in loop:IN[('order_id', 'in', orders.ids)] - ✅ Batch
for multiple recordscreate([{...}, {...}]) - ✅ Use
instead of looprecordset.write() - ✅ Use
instead of looprecordset.unlink() - ✅ Use
instead of list comprehensionmapped() - ✅ Use
before operationsfiltered() - ✅ Use
to filter non-existing recordsexists()
Field Definitions (15%)
- ✅
hasMany2one
parameter (ondelete
,cascade
,restrict
)set null - ✅
hasMonetary
parametercurrency_field - ✅
hasOne2many
parameterinverse_name - ❌ DO NOT use
for currency (useFloat
)Monetary - ❌ DO NOT use
in Odoo 18 (use<tree>
)<list> - ✅ Computed fields have
if searchable/groupable neededstore=True - ✅
includes ALL dependencies with dotted paths@api.depends
API Decorators (15%)
- ✅
uses dotted paths for related fields:@api.depends@api.depends('partner_id.email') - ❌ DO NOT use dotted paths in
(only simple field names)@api.constrains - ✅
instead of overriding@api.ondelete(at_uninstall=False)
for validation (Odoo 18!)unlink() - ✅
raises@api.constrainsValidationError - ✅
for batch create (Odoo 18)@api.model_create_multi
Performance (20%)
- ❌ DO NOT
in loopsearch() - ❌ DO NOT
in loopbrowse() - ❌ DO NOT
in loopcreate() - ❌ DO NOT
in loopwrite() - ❌ DO NOT
in loopunlink() - ✅ Use prefetch (automatic) for related field access
- ✅ Use
to fetch specific fieldssearch_read() - ✅ Use
for binary fieldsbin_size=True - ✅ Use advisory locks for concurrent operations
Transaction Management (10%)
- ✅ Use
for error isolationwith self.env.cr.savepoint(): - ❌ DO NOT continue after UniqueViolation without savepoint
- ✅ Use advisory locks to prevent serialization errors
- ✅ Group identical updates to minimize conflicts
Views & XML (5%)
- ✅ Use
instead of<list>
(Odoo 18!)<tree> - ✅ Use
for row stylingdecoration-* - ✅ Use
or shorthand withxpath
for inheritanceposition - ✅ Proper
referenceinherit_id
Security (5%)
- ✅ Has
file with proper permissionsir.model.access.csv - ✅ Use
for business logic errorsUserError - ✅ Use
for constraint violationsValidationError - ✅ Use
for permission issuesAccessError - ❌ DO NOT raise generic
Exception - ✅ Record rules defined with proper domain_force
Controllers (5%)
- ✅ Use correct
type (auth
,user
,public
)none - ✅ Use
for truly public endpoints (webhooks)auth='none' - ✅ CSRF enabled for POST (default)
- ✅
only for external webhookscsrf=False
Mixins (Additional Check)
- ✅
properly configured withmail.thread
on tracked fieldstracking=True - ✅
used for activity-enabled modelsmail.activity.mixin - ✅
properly configured with alias fieldsmail.alias.mixin - ✅
for campaign tracking when applicableutm.mixin - ✅ Proper message_post usage, not direct chatter manipulation
Testing (Additional Check)
- ✅ Tests cover new functionality
- ✅ Proper use of
decorators (standard, post_install, etc.)@tagged - ✅ TransactionCase for model tests, HttpCase for web tests
- ✅ Test data properly isolated
- ✅ Query count assertions for performance-critical code
Migration (Additional Check)
- ✅ Migration scripts in
directorymigrations/{version}/ - ✅ Pre-migration scripts for data cleanup
- ✅ Post-migration scripts for data migration
- ✅ Uses hooks (pre_init, post_init, uninstall) appropriately
- ✅ Idempotent migration scripts
Anti-Patterns to Detect
| Anti-Pattern | Consequence | Fix |
|---|---|---|
in loop | N+1 queries | Use with domain |
in loop | N INSERT statements | Batch: |
in loop | N UPDATE statements | |
in loop | N DELETE statements | |
Override for validation | Breaks module uninstall | Use |
then access | N queries | Add |
| Not supported | Use only |
in Odoo 18 | Deprecated | Use |
for currency | Precision issues | Use |
Missing on Many2one | Orphan records | Add |
Generic | Poor UX | Use , |
| Continue after UniqueViolation without savepoint | Transaction aborted | Use |
| Direct chatter manipulation instead of message_post | Breaks mail.thread features | Use with proper subtype |
Missing on tracked fields | No field tracking in chatter | Add to field definition |
Tests without decorators | Wrong test environment | Add , |
| Non-idempotent migration script | Fails on re-run | Use checks |
Missing on reference data | Data overwritten on update | Add to reference records |
Cron without and | Never runs | Add proper interval configuration |
Scoring Scale (Weighted)
Criteria (score 1-10):
- ORM & Model Methods (28%)
- Field Definitions (14%)
- API Decorators (14%)
- Performance (18%)
- Transaction Management (10%)
- Views & XML (4%)
- Security (6%)
- Controllers (6%)
Total calculation:
total = 0.28*orm + 0.14*fields + 0.14*decorators + 0.18*performance + 0.10*transaction + 0.04*views + 0.06*security + 0.06*controllers
Score anchors:
- 9-10: Excellent, no significant risks, follows all best practices
- 7-8: Good, minor issues or improvements possible
- 5-6: Average, clear risks to address, has anti-patterns
- 3-4: Poor, serious errors or regression-prone
- 1-2: Very poor, cannot merge, violates critical patterns
Report Format (Required)
## Quick Summary - [1-2 sentences summarizing key points] ## Overall Score - Total: X.X/10 - Formula: 0.28*ORM + 0.14*Fields + 0.14*Decorators + 0.18*Perf + 0.10*Trans + 0.04*Views + 0.06*Sec + 0.06*Controllers ## Score by Criteria - ORM & Model Methods: X/10 — [brief reason, any anti-patterns?] - Field Definitions: X/10 — [brief reason] - API Decorators: X/10 — [brief reason, check @api.ondelete, dotted paths] - Performance: X/10 — [brief reason, any N+1?] - Transaction Management: X/10 — [brief reason, savepoints correct?] - Views & XML: X/10 — [brief reason, using <list>?] - Security: X/10 — [brief reason] - Controllers: X/10 — [brief reason] ## Key Findings (high → low priority) ### 🔴 Critical (Must Fix) - [Severity] Brief description + consequence + fix suggestion - Code reference: `path/file.py:XX` ### 🟡 Major (Should Fix) - [Severity] Brief description + consequence + fix suggestion - Code reference: `path/file.py:XX` ### 🔵 Minor (Nice to Have) - [Severity] Brief description + improvement suggestion ## Positive Patterns Found - ✅ [Good pattern found] - Line XX ## Recommendations - [Specific, clear improvements, in priority order] ## Testing - Ran: [if any, state commands] - Missing: [tests missing or not run, N+1 scenarios]
Response Rules
- Prioritize error and risk detection first, then suggestions
- If no significant issues, clearly state "No findings"
- Cite correct file and code when needed:
path/to/file.py:XX - State assumptions when information is missing (don't guess)
- Focus on Odoo-specific patterns, not generic Python advice
- Provide code examples for complex issues
- Reference Odoo documentation when applicable
Deep Dive Checks
When reviewing, thoroughly check:
-
Does @api.depends have complete dependencies?
- Check dotted paths:
instead of justpartner_id.emailpartner_id - Missing dependencies cause N queries
- Reference:
dev/odoo-18-decorator-guide.md
- Check dotted paths:
-
Are there N+1 queries?
- Loop with
,search()
,browse()
insideread() - Solution:
withsearch_read()
domain orINread_group() - Reference:
dev/odoo-18-performance-guide.md
- Loop with
-
Are there batch operations?
,create()
,write()
in loopunlink()- Solution: Batch operations on recordset
- Reference:
dev/odoo-18-performance-guide.md
-
Is transaction safe?
- UniqueViolation handling without savepoint
- Concurrent updates without advisory lock
- Reference:
dev/odoo-18-transaction-guide.md
-
Are Odoo 18 patterns correct?
- Use
instead of<list><tree> - Use
instead of overriding@api.ondelete()unlink() - Use
for batch create@api.model_create_multi - Reference:
dev/odoo-18-view-guide.md
- Use
-
Are field definitions correct?
withMonetarycurrency_field
withMany2oneondelete- Computed field with
if neededstore=True - Reference:
dev/odoo-18-field-guide.md
-
Is exception handling correct?
,UserError
,ValidationErrorAccessError- No generic
Exception - Reference:
dev/odoo-18-security-guide.md
-
Are mixins properly configured?
with proper tracking fieldsmail.thread
for activitiesmail.activity.mixin
with alias fieldsmail.alias.mixin- Reference:
dev/odoo-18-mixins-guide.md
-
Is testing adequate?
- Tests for new functionality
- Proper use of
decorators@tagged - Query count assertions for performance
- Reference:
dev/odoo-18-testing-guide.md
-
Are migrations handled correctly?
- Proper migration script location
- Pre/post migration scripts
- Idempotent operations
- Reference:
dev/odoo-18-migration-guide.md
-
Are actions properly defined?
- Window actions with correct context
- Server actions for automation
- Cron jobs with proper intervals
- Reference:
dev/odoo-18-actions-guide.md
-
Are data files correct?
- Proper XML record structure
for reference datanoupdate="1"- CSV data properly formatted
- Reference:
dev/odoo-18-data-guide.md
-
Is manifest correct?
- All dependencies declared
- External dependencies listed
- Hooks properly configured
- Reference:
dev/odoo-18-manifest-guide.md