I found res.users
res.users does extend res.partner with delegation (that is, with _inherits, not with _inherit)
Are there any other examples available ?
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
            
                1
                
                    Odgovori
                
            
        
        
            
                3165
                
                    Prikazi
                
            
        
    I can give you some dummy example which is mentioned in the Odoo official documentation.
class Screen(models.Model):
    _name = 'delegation.screen'
    _description = 'Screen'
    size = fields.Float(string='Screen Size in inches')
class Keyboard(models.Model):
    _name = 'delegation.keyboard'
    _description = 'Keyboard'
    layout = fields.Char(string='Layout')
class Laptop(models.Model):
    _name = 'delegation.laptop'
    _description = 'Laptop'
    _inherits = {
        'delegation.screen': 'screen_id',
        'delegation.keyboard': 'keyboard_id',
    }
    name = fields.Char(string='Name')
    maker = fields.Char(string='Maker')
    # a Laptop has a screen
    screen_id = fields.Many2one('delegation.screen', required=True, ondelete="cascade")
    # a Laptop has a keyboard
    keyboard_id = fields.Many2one('delegation.keyboard', required=True, ondelete="cascade")https://www.odoo.com/documentation/12.0/developer/reference/orm.html#delegation #reference
Practical Example with res partner
class ResPartner(models.Model):
_inherit = "res.partner"
name = fields.Char("Name")
class PartnerBank(models.Model):
_name = 'res.partner.bank'
name = fields.Char("Name")
swift_code = fields.Char("Bank Swift Code")
account_number = fields.Char("Bank Account Number")
class PayrollPayee(models.Model):
_name = 'payroll.payee'
_description = 'Bank Export Template'
_inherits = {
'res.partner': 'partner_id',
'res.partner.bank': 'bank_id',
}
bank_id = fields.Many2one('res.partner.bank', required=True, ondelete="cascade")
partner_id = fields.Many2one('res.partner', required=True, ondelete="cascade" )
record = env['payroll.payee'].create({
'partner_id': env['res.partner'].create({'name': "Employee Name"}).id,
'bank_id': env['res.partner.bank'].create({'name': 'Bank', 'swift_code': 'SW1234', 'account_number': 'BJ23345434212'}).id,
})
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Prijavi| Related Posts | Odgovori | Prikazi | Aktivnost | |
|---|---|---|---|---|
|  | 2 okt. 23  | 6342 | ||
|  | 3 sep. 23  | 3237 | ||
|  | 0 maj 23  | 3187 | ||
|  | 1 maj 23  | 2487 | ||
|  | 1 apr. 23  | 2282 | 
 
                        
product.product and product.template
thank you
I meant an example of extending res.partner, not a general example of using delegation