跳至內容
選單
此問題已被標幟
1 回覆
5037 瀏覽次數

Hello all,

I can't find any place in the code to explain to me why the field 'employee' appears in the model res.users (see image below).

I have searched in the code for 'employee ='. Don't see.

I have also searched the code for 'partner_id.employee'. Don't see.

I only see this field declaration in the model res.partner.

This boolean related field doesn't seem to be declared anywhere for the model res.users... Why does it appear in the model res.users?

Thanks to comment!

Images



頭像
捨棄
最佳答案

Hi Pascal,


you can find more information about inheritance in the doc...

https://www.odoo.com/documentation/10.0/reference/orm.html#odoo.models.Model._inherits

https://www.odoo.com/documentation/10.0/reference/orm.html#inheritance-and-extension


As you can see, this field is declared on res.partner: https://github.com/odoo/odoo/blob/10.0/odoo/addons/base/res/res_partner.py#L177


And on res_users, you have the partner_id whith delegation inheritance (inheritS): https://github.com/odoo/odoo/blob/10.0/odoo/addons/base/res/res_users.py#L175

class Users(models.Model):
    _name = "res.users"
    _inherits = {'res.partner': 'partner_id'}


As explain, with inherits: "implements composition-based inheritance: the new model exposes all the fields of the _inherits-ed model but stores none of them: the values themselves remain stored on the linked record."


so if partner has field 'foo'.

user.foo ====> user.partner_id.foo


頭像
捨棄
作者

This is great! I didn't know this concept! All your explanations are clear! Big thanks for that!

相關帖文 回覆 瀏覽次數 活動
3
6月 17
6959
0
3月 24
3150
2
12月 20
9041
2
12月 23
9863
3
10月 16
6841