跳至内容
菜单
此问题已终结

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
6965
0
3月 24
3151
2
12月 20
9042
2
12月 23
9864
3
10月 16
6845