Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Delegation inheritance in Odoo v8. When is it useful?

By
Eduardo BP
on 5/3/15, 7:59 PM 1,457 views

Hi Odoo developers.

Which situations is the delegation inheritance mechanism useful in?.

Thanks Akhil. A very good answer.

Eduardo BP
on 5/4/15, 8:27 AM
4

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 5/3/15, 10:21 PM

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.

Ameen Rabea
on 3/16/16, 5:40 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/3/15, 7:59 PM
Seen: 1457 times
Last updated: 3/16/16, 6:09 AM