diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index c041dc3424f..bf7875b1466 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -791,9 +791,10 @@ abstract class CommonInvoice extends CommonObject if (!empty($hookmanager->resArray['result'])) { $this->error = $hookmanager->resArray['error']; if (!empty($hookmanager->resArray['errors'])) { - $this->errors = array_merge($this->errors, array($this->error), $hookmanager->resArray['errors']); - } else { - $this->errors = array_merge($this->errors, array($this->error)); + $this->errors = array_merge($this->errors, $hookmanager->resArray['errors']); + } + if (!in_array($this->error, $this->errors)) { + $this->errors[] = $this->error; } return $hookmanager->resArray['result']; } @@ -846,15 +847,15 @@ abstract class CommonInvoice extends CommonObject } $parameters = array(); - $reshook = $hookmanager->executeHooks('isEditable', $parameters, $this, $action); + $reshook = $hookmanager->executeHooks('isReplacable', $parameters, $this, $action); if (!empty($hookmanager->resArray['result'])) { $this->error = $hookmanager->resArray['error']; - if (!in_array($this->error, $this->errors)) { - $this->errors[] = $this->error; - } if (!empty($hookmanager->resArray['errors'])) { $this->errors = array_merge($this->errors, $hookmanager->resArray['errors']); } + if (!in_array($this->error, $this->errors)) { + $this->errors[] = $this->error; + } return $hookmanager->resArray['result']; } @@ -959,12 +960,12 @@ abstract class CommonInvoice extends CommonObject $reshook = $hookmanager->executeHooks('isErasable', $parameters, $this, $action); if (!empty($hookmanager->resArray['result'])) { $this->error = $hookmanager->resArray['error']; - if (!in_array($this->error, $this->errors)) { - $this->errors[] = $this->error; - } if (!empty($hookmanager->resArray['errors'])) { $this->errors = array_merge($this->errors, $hookmanager->resArray['errors']); } + if (!in_array($this->error, $this->errors)) { + $this->errors[] = $this->error; + } return $hookmanager->resArray['result']; } }