Clean line extrafields when deleting expedition

This commit is contained in:
Marc Guenneugues 2020-04-23 19:09:05 +02:00
parent 6819255b76
commit 3ea8d1895b

View File

@ -1280,15 +1280,23 @@ class Expedition extends CommonObject
if (!$error)
{
$main = MAIN_DB_PREFIX . 'expeditiondet';
$ef = $main . "_extrafields";
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = " . $this->id . ")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
$sql .= " WHERE fk_expedition = ".$this->id;
if ($this->db->query($sql))
if ($this->db->query($sqlef) && $this->db->query($sql))
{
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
// delete extrafields
$res = $this->deleteExtraFields();
if ($res < 0) $error++;
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";