FIX wrong alias of table if no parent and parentkey

This commit is contained in:
Regis Houssin 2022-03-24 20:48:43 +01:00
parent 391c02993d
commit ffa79c59f9

View File

@ -4413,7 +4413,11 @@ abstract class CommonObject
$sql.= " AND c.".$element['parentkey']." = p.rowid";
}
if (!empty($entity)) {
$sql.= " AND p.entity = ".((int) $entity);
if (!empty($element['parent']) && !empty($element['parentkey'])) {
$sql.= " AND p.entity = ".((int) $entity);
} else {
$sql.= " AND c.entity = ".((int) $entity);
}
}
$resql = $this->db->query($sql);
if ($resql) {