Fix strange condition

This commit is contained in:
Laurent Destailleur 2022-12-28 19:06:16 +01:00 committed by GitHub
parent 18be0b4f27
commit be03dcb8ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2985,7 +2985,7 @@ class Product extends CommonObject
$adeduire = 0;
$sql = "SELECT sum(fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet fd ";
$sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON fd.fk_facture = f.rowid ";
$sql .= " JOIN ".MAIN_DB_PREFIX."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'";
$sql .= " JOIN ".MAIN_DB_PREFIX."element_element el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
$sql .= " JOIN ".MAIN_DB_PREFIX."commande c ON el.fk_source = c.rowid ";
$sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id);
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);