fix two sides

This commit is contained in:
Quentin VIAL-GOUTEYRON 2022-09-14 09:45:18 +02:00
parent 1833add141
commit 4fcfe96690

View File

@ -3004,7 +3004,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 f.fk_statut > '.Facture::STATUS_DRAFT.' AND fd.fk_product = '.((int) $this->id);
dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE);