Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
6420 Prikazi

I'm learning about Odoo , when i read about inheritance of Odoo that make me very confused special is _inherit (no _name property) and _inherit (_name property value same as _inherit) . they look  same., i found the their defined at 

\https://www.odoo.com/forum/help-1/question/the-different-openerp-model-inheritance-mechanisms-what-s-the-difference-between-them-and-when-should-they-be-used-46#answer-190

  • If the _name as the same value as the inherited class it will do a basic inheritance.
  • If you forget to add the _inherit you will redefine the model

Could anyone explain for me what is  difference between their? ( a real situation, example )


Thank for all.

Avatar
Opusti
Best Answer

When using the _inherit and _name attributes together, Odoo creates a new model using the existing one (provided via _inherit) as a base. The new model gets all the fields, methods and meta-information (defaults & al) from its base.

When using _inherit but leaving out _name, the new model replaces the existing one, essentially extending it in-place. This is useful to add new fields or methods to existing models (created in other modules), or to customize or reconfigure them (e.g. to change their default sort order)

see examples in Odoo ORM:

Odoo ORM API

Avatar
Opusti
Avtor

Thank you !!! But i'm not clearly about case _inherit and _name have same value. Is it like _inherit and not _name ?

When using the _inherit and _name attributes together, Odoo creates a new model using the existing one (provided via _inherit) as a base. The new model gets all the fields, methods and meta-information (defaults & al) from its base.

When using _inherit but leaving out _name, the new model replaces the existing one, essentially extending it in-place. This is useful to add new fields or methods to existing models (created in other modules), or to customize or reconfigure them (e.g. to change their default sort order):

Related Posts Odgovori Prikazi Aktivnost
4
mar. 24
3246
1
okt. 23
5197
4
jun. 21
15727
2
avg. 17
12567
0
apr. 16
3113