Fix parent link was not removed on societe deletion #9106

This commit is contained in:
Maxime Kohlhaas 2018-11-01 15:41:58 +01:00
parent 4b402aa6d1
commit 29c0448a2e

View File

@ -1518,6 +1518,19 @@ class Societe extends CommonObject
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
// Remove links to subsidiaries companies
if (! $error)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET parent = NULL";
$sql.= " WHERE parent = " . $id;
if (! $this->db->query($sql))
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}
// Remove third party
if (! $error)