跳至内容
菜单
此问题已终结
1 回复
1287 查看

i want to check res_partner.employee_ids or res_users.employee_ids column data, can i create a SQL stataement and check the data in a database client like pgAdmin? if yes, please help to write Query or any other method to achieve it? 

regards


形象
丢弃
最佳答案

Both res_partner.employee_ids and res_user.employee_ids are One2many fields of hr.employee, then you can directly query the hr_employee table to retrieve the related records. Here's how you can construct the SQL query:


Sql


SELECT 

    id,

    name

FROM 

    hr_employee;

This query will select all records from the hr_employee table, which are related to either res_partner or res_user through the employee_ids One2many field.


If you need additional information from the res_partner or res_user tables, you can perform a JOIN operation:


For res_partner.employee_ids:


Sql


SELECT 

    emp.id AS employee_id,

    emp.name AS employee_name,

    rp.id AS partner_id,

    rp.name AS partner_name

FROM 

    hr_employee AS emp

JOIN 

    res_partner AS rp ON emp.partner_id = rp.id;

For res_user.employee_ids:


Sql


SELECT 

    emp.id AS employee_id,

    emp.name AS employee_name,

    ru.id AS user_id,

    ru.login AS user_login

FROM 

    hr_employee AS emp

JOIN 

    res_users AS ru ON emp.user_id = ru.id;

Adjust the JOIN conditions (emp.partner_id = rp.id or emp.user_id = ru.id) according to your actual database schema.

形象
丢弃
相关帖文 回复 查看 活动
3
11月 23
1922
0
9月 23
6138
0
3月 23
1682
1
7月 20
4891
3
1月 20
12595