@@ -918,8 +918,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0, $updatecur
918918 );
919919
920920 if ($ result < 0 ) {
921- $ this ->error = $ newinvoiceline ->error ;
922- $ this ->errors = array_merge ($ this ->errors , $ newinvoiceline ->errors );
921+ $ this ->setErrorsFromObject ($ newinvoiceline );
923922 $ error ++;
924923 break ;
925924 }
@@ -3737,8 +3736,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
37373736 $ result = $ mouvP ->reception ($ user , $ this ->lines [$ i ]->fk_product , $ idwarehouse , $ this ->lines [$ i ]->qty , 0 , $ langs ->trans ("InvoiceValidatedInDolibarr " , $ num ), '' , '' , $ this ->lines [$ i ]->batch );
37383737 if ($ result < 0 ) {
37393738 $ error ++;
3740- $ this ->error = $ mouvP ->error ;
3741- $ this ->errors = array_merge ($ this ->errors , $ mouvP ->errors );
3739+ $ this ->setErrorsFromObject ($ mouvP );
37423740 }
37433741 } else {
37443742 // TODO If warehouseid has been set into invoice line, we should use this value in priority
@@ -3790,8 +3788,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
37903788 $ result = $ mouvP ->livraison ($ user , $ productStatic ->id , $ idwarehouse , $ product_batch_qty , $ this ->lines [$ i ]->subprice , $ langs ->trans ('InvoiceValidatedInDolibarr ' , $ num ), '' , '' , '' , $ batch ->batch );
37913789 if ($ result < 0 ) {
37923790 $ error ++;
3793- $ this ->error = $ mouvP ->error ;
3794- $ this ->errors = array_merge ($ this ->errors , $ mouvP ->errors );
3791+ $ this ->setErrorsFromObject ($ mouvP );
37953792 break ;
37963793 }
37973794
@@ -3815,8 +3812,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
38153812 $ result = $ mouvP ->livraison ($ user , $ productStatic ->id , $ idwarehouse , $ product_qty_remain , $ this ->lines [$ i ]->subprice , $ langs ->trans ('InvoiceValidatedInDolibarr ' , $ num ), '' , '' , '' , $ batch ->batch );
38163813 if ($ result < 0 ) {
38173814 $ error ++;
3818- $ this ->error = $ mouvP ->error ;
3819- $ this ->errors = array_merge ($ this ->errors , $ mouvP ->errors );
3815+ $ this ->setErrorsFromObject ($ mouvP );
38203816 }
38213817 }
38223818 }
@@ -3828,8 +3824,7 @@ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger
38283824 $ result = $ mouvP ->livraison ($ user , $ this ->lines [$ i ]->fk_product , $ idwarehouse , $ this ->lines [$ i ]->qty , $ this ->lines [$ i ]->subprice , $ langs ->trans ("InvoiceValidatedInDolibarr " , $ num ));
38293825 if ($ result < 0 ) {
38303826 $ error ++;
3831- $ this ->error = $ mouvP ->error ;
3832- $ this ->errors = array_merge ($ this ->errors , $ mouvP ->errors );
3827+ $ this ->setErrorsFromObject ($ mouvP );
38333828 }
38343829 }
38353830 }
@@ -4282,7 +4277,7 @@ public function addline(
42824277 $ result = $ product ->fetch ($ fk_product );
42834278 $ product_type = $ product ->type ;
42844279
4285- if (getDolGlobalString ('STOCK_MUST_BE_ENOUGH_FOR_INVOICE ' ) && $ product_type == 0 ) {
4280+ if (getDolGlobalString ('STOCK_MUST_BE_ENOUGH_FOR_INVOICE ' ) && $ product -> isStockManaged () ) {
42864281 // get real stock
42874282 $ productChildrenNb = 0 ;
42884283 if (getDolGlobalInt ('PRODUIT_SOUSPRODUITS ' )) {
@@ -4632,7 +4627,7 @@ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_star
46324627 $ result = $ product ->fetch ($ line ->fk_product );
46334628 $ product_type = $ product ->type ;
46344629
4635- if (getDolGlobalString ('STOCK_MUST_BE_ENOUGH_FOR_INVOICE ' ) && $ product_type == 0 ) {
4630+ if (getDolGlobalString ('STOCK_MUST_BE_ENOUGH_FOR_INVOICE ' ) && $ product -> isStockManaged () ) {
46364631 // get real stock
46374632 $ productChildrenNb = 0 ;
46384633 if (getDolGlobalInt ('PRODUIT_SOUSPRODUITS ' )) {
0 commit comments