Skip to Content
Menu
This question has been flagged

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



Avatar
Discard
Best Answer

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


Avatar
Discard
Author

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

Related Posts Replies Views Activity
3
Jun 17
5800
0
Mar 24
2101
2
Dec 20
7886
2
Dec 23
8634
3
Oct 16
5694