FIX #39425 Missing rollback when stock movement fails in Expedition::valid() (#39426)

* Fix missing rollback when stock movement fails in Expedition::valid()

When STOCK_CALCULATE_ON_SHIPMENT is enabled and manageStockMvtOnEvt() fails while validating a shipment, the method returned -2 directly without calling $this->db->rollback(), unlike every other error branch in this method. Changed to increment $error instead, so execution falls through to the existing commit/rollback block at the end of valid().

Fixes #39425

* Update expedition.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
support-accellier 2026-08-13 07:29:28 +05:30 committed by GitHub
parent b9a31b4563
commit 7e72304271
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1058,7 +1058,7 @@ class Expedition extends CommonObject
if (!$error && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) {
$result = $this->manageStockMvtOnEvt($user, "ShipmentValidatedInDolibarr");
if ($result < 0) {
return -2;
$error++;
}
}
@ -1071,9 +1071,11 @@ class Expedition extends CommonObject
}
// TODO : load the origin object to trigger the right setStatus according to origin object
$ret = $this->setStatut(Commande::STATUS_SHIPMENTONPROCESS, $this->origin_id, $this->origin, $triggerKey);
if (!$ret) {
$error++;
if (!$error) {
$ret = $this->setStatut(Commande::STATUS_SHIPMENTONPROCESS, $this->origin_id, $this->origin, $triggerKey);
if (!$ret) {
$error++;
}
}
if (!$error && !$notrigger) {