Overview
Many difficulties with inheritance in Odoo come from a simple misunderstanding: Odoo models are not regular Python classes.
Once the role of the registry is understood, inheritance behavior becomes clearer and more predictable.
This article explains Odoo inheritance in practical way, without assuming deep internal knowledge.
Odoo Models Are Built at Runtime
In standard Python:
- A class directly inherits from another class
- The parent–child relationship is clear and static
In Odoo:
- A model is assembled when the server starts
- Multiple classes from different modules are merged
- The final model exists only in the registry
Each Python file contributes part of the behavior, not the whole model.
The Role of the Registry
The registry is responsible for:
- Collecting all model definitions
- Combining inherited models into one runtime class
- Defining the execution order using Python’s MRO
Because of this:
- There is no single “main” class
- The execution order depends on how modules are loaded
- Adding a module can change behavior without modifying code
Inheritance as Behavior Layering
Instead of parent–child inheritance, Odoo uses layered behavior:
- Each module adds or modifies logic
- All layers are executed in sequence
- The final behavior is the result of all layers combined
This approach allows Odoo to stay highly modular and extensible.
How super() Fits In
In Odoo, super() does not call a specific parent class.
It moves execution to the next layer defined by the registry and MRO.
Calling super() ensures:
- Other modules can run their logic
- Core features continue to work
- The execution chain remains complete
This is why super() is consistently used across Odoo’s core code.
Common Sources of Confusion
Developers often struggle when they:
- Expect _inherit to behave like Python subclassing
- Assume their override runs last
- Ignore module load order
- Skip super() without realizing the impact
These issues are conceptual, not technical.
A Clear Mental Model
To work effectively with Odoo inheritance:
- Think in layers, not parents
- Trust the registry, not the file structure
- Use super() to continue execution, not to “go up”
With this mindset, Odoo inheritance becomes easier to reason about and safer to extend.
Once the registry is understood, Odoo’s inheritance model feels consistent rather than confusing.
