콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
6514 화면

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.

아바타
취소
베스트 답변

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

아바타
취소
작성자

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

관련 게시물 답글 화면 활동
4
3월 24
3327
1
10월 23
5301
4
6월 21
15810
2
8월 17
12618
0
4월 16
3189