Merge pull request #13724 from simicar29/11.0-supplierinvoice

Clean line extrafields when deleting supplier invoice
This commit is contained in:
Laurent Destailleur 2020-04-23 18:35:34 +02:00 committed by GitHub
commit 388e98fdf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1180,10 +1180,14 @@ class FactureFournisseur extends CommonInvoice
if (!$error)
{
$main = MAIN_DB_PREFIX . 'facture_fourn_det';
$ef = $main . "_extrafields";
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture_fourn = $rowid)";
$resqlef = $this->db->query($sqlef);
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
if ($resqlef && $resql)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
@ -3141,6 +3145,11 @@ class SupplierInvoiceLine extends CommonObjectLine
$this->deleteObjectLinked();
$result = $this->deleteExtraFields();
if ($result < 0) {
$error++;
}
if (!$error) {
// Supprime ligne
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';