Delegation Inheritance in Odoo 17 and Its Use Cases

CelineGeorge1 900 views 6 slides Jul 03, 2024
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

There are 3 types of inheritance in odoo Classical, Extension, and Delegation. Delegation inheritance is used to sink other models to our custom model. And there is no change in the views. This slide will discuss delegation inheritance and its use cases in odoo 17.


Slide Content

Delegation Inheritance in Odoo 17 Enterprise

Introduction Enterpr ise There are 3 types of inheritance in odoo Classical, Extension, and Delegation. Delegation inheritance is used to sink other models to our custom model. And there is no change in the views. This slide will discuss delegation inheritance and its use cases in odoo 17.

Enterprise Delegation inheritance is used to sink other models to our custom model 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. In delegate inheritance, the attributes used are _inherits.

Enterprise Then we can see an example of the delegation inheritance. Consider the product.product model here inherits the product.template model field “product_tmpl_id”. class ProductKit(models.Model): _name = 'product.kit' _inherits = {'product.template': 'product_template_id'} _description = 'Product Package' _inherit = ['mail.thread', 'mail.activity.mixin'] product_template_id = fields.Many2one ('product.template',string='Related_product_id',auto_join=True, index=True, ondelete="cascade", required=True)

Enterprise Syntax for delegation inheritance: _inherits = {'product.template': 'product_template_id'} Product.template is the model which is going to be used in delegation inheritance. And product_template_id is a Many2one field that is linked with the model product.kit As a result, the database tables will have both field for the inherited object and the information from your model. For this inheritance, we must declare a Many2one field of the inheriting model. In this case, all fields in the model product_template are now available in the model product.kit.

For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com