diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2c31c413e7a..5d4654807fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -586,7 +586,7 @@ class Commande extends CommonOrder $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num)); if ($result < 0) { $error++; - $this->error = $mouvP->error; + $this->setErrorsFromObject($mouvP); } } if ($error) { @@ -721,7 +721,7 @@ class Commande extends CommonOrder $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref)); if ($result < 0) { $error++; - $this->error = $mouvP->error; + $this->setErrorsFromObject($mouvP); break; } } @@ -1861,7 +1861,7 @@ class Commande extends CommonOrder return -1; } } else { - $this->error = $this->line->error; + $this->setErrorsFromObject($this->line); dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -2184,8 +2184,7 @@ class Commande extends CommonOrder return -1; } } else { - $this->error = $line->error; - $this->errors = $line->errors; + $this->setErrorsFromObject($line); $this->db->rollback(); return -2; } @@ -2522,7 +2521,7 @@ class Commande extends CommonOrder } } else { $this->db->rollback(); - $this->error = $line->error; + $this->setErrorsFromObject($line); return -1; } } else { @@ -3350,7 +3349,7 @@ class Commande extends CommonOrder $this->db->commit(); return $result; } else { - $this->error = $this->line->error; + $this->setErrorsFromObject($this->line); $this->db->rollback(); return -1; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 928eb01835f..50c4366bac7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3737,8 +3737,7 @@ class Facture extends CommonInvoice $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num), '', '', $this->lines[$i]->batch); if ($result < 0) { $error++; - $this->error = $mouvP->error; - $this->errors = array_merge($this->errors, $mouvP->errors); + $this->setErrorsFromObject($mouvP); } } else { // TODO If warehouseid has been set into invoice line, we should use this value in priority @@ -3790,8 +3789,7 @@ class Facture extends CommonInvoice $result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch); if ($result < 0) { $error++; - $this->error = $mouvP->error; - $this->errors = array_merge($this->errors, $mouvP->errors); + $this->setErrorsFromObject($mouvP); break; } @@ -3815,8 +3813,7 @@ class Facture extends CommonInvoice $result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch); if ($result < 0) { $error++; - $this->error = $mouvP->error; - $this->errors = array_merge($this->errors, $mouvP->errors); + $this->setErrorsFromObject($mouvP); } } } @@ -3828,8 +3825,7 @@ class Facture extends CommonInvoice $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); if ($result < 0) { $error++; - $this->error = $mouvP->error; - $this->errors = array_merge($this->errors, $mouvP->errors); + $this->setErrorsFromObject($mouvP); } } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2279ccc3f97..3a8186043ed 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -431,8 +431,7 @@ class Contrat extends CommonObject $result = $contratline->active_line($user, $date_start, !empty($date_end) ? $date_end : -1, $comment); // This call trigger LINECONTRACT_ACTIVATE if ($result < 0) { $error++; - $this->error = $contratline->error; - $this->errors = $contratline->errors; + $this->setErrorsFromObject($contratline); break; } } @@ -1642,8 +1641,7 @@ class Contrat extends CommonObject $contractline->id = $contractlineid; $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->errors = array_merge($this->errors, $contractline->errors); - $this->error = $contractline->error; + $this->setErrorsFromObject($contractline); $error++; } @@ -2680,8 +2678,7 @@ class Contrat extends CommonObject $result = $clonedObj->addline($line->description, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_start, $line->date_cloture, 'HT', 0, $line->info_bits, $line->fk_fournprice, $line->pa_ht, $line->array_options, $line->fk_unit, $line->rang); if ($result < 0) { $error++; - $this->error = $clonedObj->error; - $this->errors[] = $clonedObj->error; + $this->setErrorsFromObject($clonedObj); } } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 47a94e3a0de..0faebc0ef09 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1926,10 +1926,7 @@ class FactureFournisseur extends CommonInvoice $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num)); } if ($result < 0) { - $this->error = $mouvP->error; - if (count($mouvP->errors)) { - $this->errors = $mouvP->errors; - } + $this->setErrorsFromObject($mouvP); return -2; } }