Edi Santoso
Odoo and Python Developer
drink a tea to enjoying the life

odoo sql query get res_partner and the childs

sql query :

SELECT id,name,company_type,street,street2,city,zip,country_id, phone,
COALESCE(phone, (select phone from res_partner b where parent_id = a.id limit 1)) as phone_child,
fax, email,
COALESCE(email, (select email from res_partner c where parent_id = a.id limit 1)) as email_child,
karyawan,customer,supplier,company_id,
regexp_replace(comment, '\r|\n', '', 'g') as comment,
COALESCE('', (select regexp_replace(comment, '\r|\n', '', 'g') as comment from res_partner d where parent_id = a.id limit 1)) as comment_child
FROM res_partner a WHERE parent_id IS NULL ORDER BY id ASC;