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

What is Inheritance by delegation? Can you share an example?

By
Karthik Arumugam
on 7/3/15, 3:19 AM 438 views

Hi, I am new to the openerp concepts can any explain me the concept behind the "Inheritance by delegation" with an example.

2

Axel Mendoza

--Axel Mendoza--
10318
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/10/15, 4:38 AM

Inheritance by delegation can be described as a composition model joining the fields and functions of the related model as one(but separated) in a new model using always a field many2one for expressing the relation. Take a simple example to show the syntax:

#product.product and product.template



class product_template(osv.osv): 
_name = "product.template"
...

product_template()


class product_product(osv.osv):

_name = "product.product"

_description = "Product"

_inherits = {'product.template': 'product_tmpl_id'}

...

_columns = {

'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True, auto_join=True),

}

...

product_product()


As you see product.product has a many2one with product.template and inherits from product.template using the relation field with that model. As results product.product forms/tree/objects values in general could use fields from product.template as declared local in the product.product model, but the field values of product.template will be stored in product.template where they belongs. Its a way of simple manage the other model from here.

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

2 follower(s)

Stats

Asked: 7/3/15, 3:19 AM
Seen: 438 times
Last updated: 8/14/15, 1:52 AM