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

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


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

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 11 23
2047
0
thg 9 23
6267
0
thg 3 23
1815
1
thg 7 20
5030
3
thg 1 20
12724