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 management
- MRP
This question has been flagged
1
Reply
1242
Views
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!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Oct 23
|
3959 | ||
|
3
Sep 23
|
1008 | ||
|
0
May 23
|
1447 | ||
|
1
May 23
|
926 | ||
|
1
Apr 23
|
810 |
product.product and product.template
thank you
I meant an example of extending res.partner, not a general example of using delegation