Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5032 Lượt xem

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



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 6 17
6955
0
thg 3 24
3149
2
thg 12 20
9039
2
thg 12 23
9862
3
thg 10 16
6840