Odoo Inheritance Explained: _inherit vs _name vs _inherits

If you’ve worked with Odoo for a while, you’ve probably come across inheritance—and maybe even felt a bit confused by it.

At first glance, _inherit, _name, and _inherits might seem similar. But in reality, they serve very different purposes. Understanding this properly can make a huge difference in how clean, scalable, and maintainable your modules are.

In this blog, let’s break it down in a simple, practical way—so you know exactly when to use what.

Why Inheritance Matters in Odoo

Odoo is built around reusable models like:

  • res.partner (Contacts)
  • sale.order (Sales)
  • product.template (Products)
  • hr.employee (Employees)

Now imagine rewriting all of this logic every time you need a small customization. That would be a nightmare.

This is where inheritance comes in.

It allows you to:

  • Extend existing functionality
  • Reuse fields and methods
  • Avoid duplicate code
  • Keep your customizations upgrade-safe

In short, inheritance is what makes Odoo development efficient and powerful.

_inherit — When You Want to Extend

Think of _inherit as:

 “I don’t want to create something new. I just want to improve what already exists.”

This is the most commonly used inheritance in Odoo.

Example

from odoo import models, fields


class ResPartner(models.Model):

_inherit = 'res.partner'


customer_code = fields.Char("Customer Code")

What’s happening here?

  • You’re extending the existing res.partner model
  • Adding a new field (customer_code)
  • No new table is created

You’re simply enhancing the same model.

When should you use it?

Use _inherit when you want to:

  • Add fields to existing models
  • Override methods
  • Customize workflows
  • Extend standard behavior

This is your go-to option in most cases.

_name — When You Want Something Completely New

Now think of _name as:

 “I want to build something from scratch.”

Example

from odoo import models, fields


class LibraryBook(models.Model):

_name = 'library.book'

_description = 'Library Book'


name = fields.Char("Book Name")

author = fields.Char("Author")

What’s happening here?

  • You’re creating a brand-new model
  • Odoo creates a new database table
  • It’s completely independent

This is not an extension—this is creation.

When should you use it?

Use _name when you want to:

  • Build new modules
  • Create new business objects
  • Define your own workflows

👉 Example: booking systems, approvals, custom master data, etc.

_inherits — When You Want to Reuse Without Copying

This is where things get interesting.

Think of _inherits as:

“I want a new model, but I also want to reuse another model’s fields.”

Example

from odoo import models, fields


class HospitalPatient(models.Model):

_name = 'hospital.patient'

_inherits = {'res.partner': 'partner_id'}


partner_id = fields.Many2one('res.partner', required=True, ondelete='cascade')

patient_id = fields.Char("Patient ID")

What’s happening here?

  • You create a new model (hospital.patient)
  • It is linked to res.partner
  • All partner fields (name, phone, email, etc.) are available

Behind the scenes:

  • Data is stored in multiple tables
  • But it behaves like a single model

When should you use it?

Use _inherits when:

  • Your model depends heavily on another model
  • You want to reuse fields without duplicating them
  • You need separate identity but shared structure

👉 Example: Employee ↔ Partner, Patient ↔ Contact

The Difference (Made Simple)

TypeMeaning
_inherit“Extend what already exists”
_name“Create something new”
_inherits“Create new, but reuse another model’s data”

Common Mistakes Developers Make

This is where many developers struggle:

  • Mixing up _inherit and _inherits
  • Using _inherits when _inherit is enough
  • Expecting _inherit to create a new model
  • Forgetting the linking field in _inherits

These mistakes can lead to bad database design and complex bugs.

Best Practices

To keep your code clean and maintainable:

  • Use _inherit for most customizations
  • Use _name for independent models
  • Use _inherits only when delegation is truly needed
  • Avoid overcomplicating your model structure

 Always choose based on business logic, not convenience.

Odoo inheritance is powerful—but only when used correctly.

  • _inherit → Extend existing models
  • _name → Create new models
  • _inherits → Delegate and reuse fields

Once you understand this clearly, your module design becomes:

  • Cleaner
  • More scalable
  • Easier to maintain

Have an Odoo Requirement? Let's Talk.

Whether you're planning a new Odoo implementation, struggling with performance issues, or looking to build custom integrations — we're here to help.

Our team works with businesses of all sizes to design, develop, and optimize Odoo solutions that actually fit the way you work. From queue job architecture to full-scale ERP customization, we've got you covered.

📩 Reach out to us at: contact@opturatech.com 🌐 Whatsapp us at: +91 7025199191.

Or simply fill out our Contact Form → and we'll get back to you within one business day.

Share this post
Tags
Archive
Passing Context Between Views & Actions in Odoo (Explained Simply)