diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 574553016b4..d1b0ca0164c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9729,23 +9729,24 @@ abstract class CommonObject $tmpforobjectclass = get_class($this); $tmpforobjectlineclass = ucfirst($tmpforobjectclass).'Line'; + $this->db->begin(); + // Call trigger $result = $this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); if ($result < 0) { - return -1; + $error++; } // End call triggers - $this->db->begin(); + if (empty($error)) { + $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $idline); - $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line; - $sql .= " WHERE rowid = ".((int) $idline); - - dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = "Error ".$this->db->lasterror(); - $error++; + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } } if (empty($error)) {