Standard Odoo model inheritance

This type of inheritance is used when you want to extend the already existing model with additional fields, methods or other functionalities.
For example, if you want to add a new field in the existing model res.partner, you can do that by inheriting the model res.partner and defining the new field.

from openerp import models

class PartnerContact(models.Model):
    _inherit = 'res.partner'

    work_hours = fields.Float(string='Work Hours')

Also with this inheritance, you can override existing fields and methods in order to change their current functionality.

The important thing here is to remember that when you want to implement this kind of inheritance you don’t need to define _name in the model, only add the name of the model which you want to override as a value in the _inherit parameter.

Leave a Reply

Your email address will not be published. Required fields are marked *