Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
9745 Widoki

Hello all,

I'm on odoo 10.

1) After an hour searching, I can't find where is declared the many2one field user_id of the model hr_employee... Where is the 'user_id = fields....' in the Python code?

2) Also, still in the model hr_employee, why this sql works :

select distinct("resource_id") FROM "hr_employee" where "resource_id" is not null

But not this one (ERROR:  column "user_id" does not exist) :

select distinct("user_id") FROM "hr_employee" where "user_id" is not null

Both fields resource_id and user_id are many2one fields on the model hr_employee...


Thanks for you help!

Awatar
Odrzuć
Najlepsza odpowiedź

Hi Pascal,

The user_id (Related User) field is created in resource module resource.resouce object and hr.employee inherits resource object.

So basically you have to use join query to fetch the user_id field.

SELECT resource.user_id FROM hr_employee emp 
LEFT JOIN resource_resource resource ON res.id=emp.resource_id

Hope this will help you,

Thanks

Awatar
Odrzuć
Najlepsza odpowiedź

The employee is a resource and the resource is the one that has a user_id. Following with the example in sql should be.

Select distinct user_id 
from hr_employee e inner join resource_resource res ON e.resource_id=res.id
where user_id is not null

Or use the ORM employee.user_id

Sorry my english is not very good

i hope this are usefull for you

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
mar 21
5316
4
mar 15
12134
2
mar 15
6855
1
lis 23
5952
1
mar 24
7125