Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
5883 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää
Tekijä

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):

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
4
maalisk. 24
2578
1
lokak. 23
4552
4
kesäk. 21
15123
2
elok. 17
12205
0
huhtik. 16
2691