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:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
1
الرد
2247
أدوات العرض
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,
})
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
2
أكتوبر 23
|
5503 | ||
|
3
سبتمبر 23
|
2379 | ||
|
0
مايو 23
|
2450 | ||
|
1
مايو 23
|
1914 | ||
|
1
أبريل 23
|
1723 |
product.product and product.template
thank you
I meant an example of extending res.partner, not a general example of using delegation