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

Hi Odoo developers.

Which situations is the delegation inheritance mechanism useful in?.

아바타
취소
작성자

Thanks Akhil. A very good answer.

베스트 답변

Hi,

    The delegation inheritance inherits only fields and methods are not inherited. It can be useful, when we need to embed a model in our current model without affecting the existing views, but we want to have the fields of inherited objects.

    Any field not found in current model will be taken from the inherited models. You can have multiple inheritance, so that the new table created in DB contains your new fields and fields which delegates the inherited object fields (fields storing IDs from inherited tables.


You can find an example in hr.py in hr module:


class hr_employee(osv.osv):

_name = "hr.employee"

_description = "Employee"

_order = 'name_related'

_inherits = {'resource.resource': "resource_id"}

.................

.................

columns{

'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True, auto_join=True),


}

Here hr.employee objects inherits resource.resource object by delegation and all fields of resource.resource object are accessible from hr.employee. For each employee a resource record will be created and its foreign key is stored in resource_id. The fields values of resource.resource synchronized with the hr.employee object.

Refer the link also: https://www.odoo.com/documentation/8.0/reference/orm.html#inheritance-and-extension


아바타
취소

But in this case, do I have to build all the views manually from scratch? Is there a way to say to Odoo "use the original exiting views of the main module, and do the following modifications"? I mean like the basic class inheritance. As you know, basic Class Inheritance uses the same main views because the new module name is actually typical to the main module. But in prototype & delegation it has different name.

관련 게시물 답글 화면 활동
0
5월 15
7382
1
11월 22
3434
0
6월 21
5984
0
3월 21
2791
2
1월 20
21777