Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1452 Ansichten

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


Avatar
Verwerfen
Beste Antwort

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.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
3
Nov. 23
2091
0
Sept. 23
6340
0
März 23
1836
1
Juli 20
5108
3
Jan. 20
12871