March 2018
Beginner to intermediate
336 pages
8h 22m
English
Delegation inheritance is less frequently used, but it can provide very convenient solutions. It is used through the _inherits attribute (note the additional "s") for dictionary mapping inherited models with fields linking to them.
A good example of this is the standard user's model, res.users; it has a partner model embedded in it:
from odoo import fields, modelsclass User(models.Model):
_name = 'res.users'
_inherits = {'res.partner': 'partner_id'}
partner_id = fields.Many2one('res.partner')
With delegation inheritance, the res.users model embeds the inherited model, res.partner, so that when a new User class is created, a partner is also created and a reference to it is kept in the partner_id ...
Read now
Unlock full access