Merge pull request #20311 from Easya-Solutions/14.0_fix_error_propagation_and_triggers_position_on_delete_propal_line
[FIX] errors propagation and trigger position on delete proposal line
This commit is contained in:
commit
62f6686ad0
@ -231,8 +231,11 @@ if (empty($reshook)) {
|
|||||||
// Remove line
|
// Remove line
|
||||||
$result = $object->deleteline($lineid);
|
$result = $object->deleteline($lineid);
|
||||||
// reorder lines
|
// reorder lines
|
||||||
if ($result) {
|
if ($result > 0) {
|
||||||
$object->line_order(true);
|
$object->line_order(true);
|
||||||
|
} else {
|
||||||
|
$langs->load("errors");
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
|
|||||||
@ -980,6 +980,8 @@ class Propal extends CommonObject
|
|||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
$this->error = $line->error;
|
||||||
|
$this->errors = $line->errors;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -4166,7 +4168,17 @@ class PropaleLigne extends CommonObjectLine
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".((int) $this->rowid);
|
if (!$notrigger) {
|
||||||
|
// Call trigger
|
||||||
|
$result = $this->call_trigger('LINEPROPAL_DELETE', $user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propaldet WHERE rowid = " . ((int) $this->rowid);
|
||||||
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
|
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
// Remove extrafields
|
// Remove extrafields
|
||||||
@ -4175,27 +4187,21 @@ class PropaleLigne extends CommonObjectLine
|
|||||||
$result = $this->deleteExtraFields();
|
$result = $this->deleteExtraFields();
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
|
||||||
// Call trigger
|
|
||||||
$result = $this->call_trigger('LINEPROPAL_DELETE', $user);
|
|
||||||
if ($result < 0) {
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// End call triggers
|
|
||||||
|
|
||||||
$this->db->commit();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
} else {
|
} else {
|
||||||
$this->error = $this->db->error()." sql=".$sql;
|
$this->error = $this->db->error() . " sql=" . $sql;
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
|
} else {
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user