Quick reference for Odoo module development (v16.0 - v19.0). Strictly adhere to these rules.
- No
cr.commit(): Never call commit outside migrations/crons. - Define ACLs: Every model must have a line in
security/ir.model.access.csv. - No SQL Injection: Parameterize raw SQL:
cr.execute(query, params). UseSQL()class in 17.0+. - XML IDs: Prefix all XML IDs with the technical module name (e.g.
<record id="module_name.view_id" ...>). - Clean Errors: Never use bare
except: pass. Catch specific errors and log using_logger.
| Version | List View | Conditional UI | Grouping ORM | Test Framework |
|---|---|---|---|---|
| 16.0 | <tree> |
attrs="{'invisible': [('state', '=', 'draft')]}" |
read_group() |
QUnit |
| 17.0 | <tree> |
invisible="state == 'draft'" |
read_group() |
QUnit / OWL 2 |
| 18.0 | <list> |
invisible="state == 'draft'" |
_read_group() |
Hoot |
| 19.0 | <list> |
invisible="state == 'draft'" |
_read_group() |
Hoot |
- Detect version via
scripts/detect_odoo_version.py. - Scaffold scaffolding via
scripts/scaffold_module.py. - Develop logic (models, views, security, tests).
- Run validation:
python3 scripts/check_anti_patterns.py --jsonpython3 scripts/check_acls.py --jsonpython3 scripts/check_test_coverage.py --jsonpython3 scripts/validate_manifest.py --json
- Apply auto-fixes:
python3 scripts/autofix_linter.py.
- Codegraph: Use
codegraph_exploreto trace model inheritance (_inherit) and field extensions. - Engram: Use
mem_saveto record complex Odoo bug resolutions andmem_searchto find past conventions.