Skip to Content
Menú
This question has been flagged
2 Respostes
11329 Vistes

Hi everyone, I'm new to Odoo, and I'm working with v11. Currently I got a problem when I try to figure out "Contact tacker" module. It only show records that belongs to " Pieter Parker", so I had a look the filter in "hr_expense_views.xml" file and I find "[('employee_id.user_id', '=', uid)]",  can anyone explain the reason for using "XXX.user_id"?


please help me out

Avatar
Descartar
Best Answer

Hi,

Are you looking reason for why employee_id.user_id is used ?

In this case what they have done is that, for that user he can only view his own records, to achieve this the employee record and logged in user has to checked.


uid will hold the value of the current logged in user's id. Then it has to be compared with related user of the employee. All the employees is related to user, opening the employee form you can see a field named Related user.


The employee_id have the hr.employee record, from this record we can access the related user of an employee, so using the . operator, related user is accessed by employee_id.user_id and it is compared with uid, then for the records for which both matches will be shown.


If employee_id = uid , is given as filter , then employees id will get compared with the logged in users id.

Thanks

Avatar
Descartar
Autor

Niyas, thank you for your answer. It helps a lot for me to understand the structure.

I guess the key is "Related User" in employee form, it is the way to link employee and user together (even they have different id in database), am I right? what about their email address, employee No. or name (unique) ?

And also you said that "All the employees is related to user " so what will happen if I keep that field empty, showing error or unable to view their expenses since they don't have any related user?

Thanks!

Autor Best Answer

Niyas, thank you for your answer, and sorry for can't making comment directly under your reply.

It helps a lot for me to understand the structure.

I guess the key is "Related User" in employee form, it is the way to link employee and user together (even they have different  id in database), am I right? what about their email address, employee No. or name (unique) ?

and also you said that "All the employees is related to user " so what will happen if I keep that field empty, showing error or unable to view their expenses since they don't have any related user?

Avatar
Descartar
Related Posts Respostes Vistes Activitat
5
de set. 20
12655
1
de març 15
5131
0
de març 15
3812
2
de març 15
7319
6
de maig 24
70705