top of page

Shared Interests Group

Public·540 members

What is the difference between _inherit vs _inherits in Odoo?

The key difference lies in how Odoo extends models. inherit is used for extending an existing model's fields and behavior directly, while inherits allows your model to include another model's fields via delegation (i.e., a kind of composition, not inheritance in the classical OOP sense).


When customizing Odoo for specific business needs, understanding the nuances between inherit and inherits is critical.

  • Use _inherit when you want to modify an existing model, such as adding a new field to res.partner or overriding a method in sale.order. This method keeps the same database table but extends functionality.

  • On the other hand, inherits is used to create a new model that delegates fields from another model. For example, if you’re creating a new model linkly.payment.profile and want to reuse fields from res.partner, inherits allows you to do that without directly modifying the original model.

This distinction becomes particularly important in real-world integrations, such as building a custom Linkly EFTPOS integration in Odoo POS. You might use inherits to create a new payment processing model that incorporates fields from the account.payment model while keeping your custom logic isolated. Meanwhile, inherit could be used to modify existing behavior of the pos.order model to capture EFTPOS transaction details.

Understanding this difference helps ensure better modularity, cleaner database structure, and easier maintenance when scaling your Odoo apps—especially when integrating with external payment solutions like Linkly.

4 Views

Great explanation on the difference between inherit and inherits in Odoo!

To add on, understanding these two concepts is crucial when you're customizing or scaling your Odoo implementation. This is especially true when working with third-party integrations or developing modular apps.

At a high level:

  • Use _inherit when you want to extend or modify an existing model directly—ideal for adding fields, views, or overriding methods.

  • Use _inherits when you want to reuse another model’s fields in a new model through delegation, helping maintain a clean separation of concerns.

For example, in complex use cases like integrating with external systems such as Linkly for EFTPOS in Odoo POS, both mechanisms play a role. You might use inherits to create a clean, standalone model that still leverages account.payment, while inherit can be used to hook into pos.order to capture transaction data.

If you're navigating these kinds of advanced customizations, leveraging Odoo Consulting Services can help ensure that your architecture is robust, scalable, and future-proof. A good consulting partner will help you make the right design choices between inherit and inherits, depending on your business requirements.

Members

©2024 CityDanceNY

bottom of page