diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 90c54a5fefe..40937fc77e5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3140,6 +3140,8 @@ class OrderLine extends CommonOrderLine $error=0; + $this->db->begin(); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';"; dol_syslog("OrderLine::delete sql=".$sql); @@ -3165,7 +3167,18 @@ class OrderLine extends CommonOrderLine if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - return 1; + if (!$error) { + $this->db->commit(); + return 1; + } + + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } else {