Blog

News & Events
Different Types of Inheritance in Odoo 16
June 12, 2023
In Odoo 16, a popular open-source ERP system, there are different inheritances that you can use to extend and customize the functionality of existing models. These inheritance types provide flexibility and modularity in Odoo development, allowing you to customize the system to meet specific business requirements. Here are the different inheritances in Odoo 16.
-
Class Inheritance
Payton code:
class NewModel(models.Model): _inherit = “base. model” new_field_name = fields.Char() def new_method(self): # Custom implementation Pass
-
Prototype Inheritance
XML code:
<record id="new_view_id" model="ir.ui.view"> <field name="name">new.view</field> <field name="model">base.model</field> <field name="inherit_id" ref="base.view_form"/> <field name="arch" type="xml"> <!-- Customize the view --> </field> </record>
-
Function Inheritance
DOWNLOAD ERP
Python code:
class NewModel(models.Model):_inherit = 'base.model' @api.multi def existing_function(self): # Custom implementation result = super(NewModel, self).existing_function() # Modify result or add additional functionality return result
-
Workflow Inheritance
XML code:
<record id="new_workflow_id" model="workflow"> <field name="name">new.workflow</field> <field name="osv">base.model</field> <field name="on_create">True</field> <field name="state">draft</field> <!-- Customize the workflow states and transitions --> </record>
-
Data Inheritance
<record id="new_data_id" model="ir.model.data"> <field name="name">new_data_record</field> <field name="model">base.model</field> <field name="module">my_module</field> <field name="res_id">base.model_id</field> <!-- Customize the data record --> </record>These inheritance types provide powerful mechanisms for extending and customizing Odoo models, views, functions, workflows, and data. Request Your Free Quote