Se rendre au contenu
Menu
Cette question a été signalée

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
Ignorer
Meilleure réponse

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
Ignorer
Auteur

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

Publications associées Réponses Vues Activité
3
juin 17
6959
0
mars 24
3150
2
déc. 20
9041
2
déc. 23
9862
3
oct. 16
6840