Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
10687 Lượt xem

Hi Odoo developers.

Which situations is the delegation inheritance mechanism useful in?.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Akhil. A very good answer.

Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 15
7379
1
thg 11 22
3433
0
thg 6 21
5977
0
thg 3 21
2791
2
thg 1 20
21773