From 0255512c1c2fc5d64694c9ef581430ea9a2aff8f Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Wed, 3 Sep 2025 16:08:00 +0200 Subject: [PATCH] The signature of the Sale order ->cancel() method and shipment ->cancel() has been modified to introduce the $user param like for other methods that modify a status. --- ChangeLog | 1 + htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 3 ++- htdocs/core/actions_massactions.inc.php | 2 +- htdocs/expedition/card.php | 2 +- htdocs/expedition/class/expedition.class.php | 9 +++++---- htdocs/fourn/class/fournisseur.commande.class.php | 6 ++---- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3b19e0dbd3..1d7bf8bcbee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ The following changes may create regressions for some external modules, but were * Parameters $maxlen and $notooltip of Contract have been inverted to follow the standard. It was breaking the common use of getNomUrl() but if you were using the parameter maxlen (rare) by using the old signature, result may be a tooltip that is no more visible on ref printed by you module. * Removed array $MAP_ID_TO_CODE that was a duplicate of array "array_flip($categ->MAP_ID)" +* The signature of the Sale order ->cancel() method and shipment ->cancel() has been modified to introduce the $user param like for other methods that modify a status. diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d3139f66a4d..7d989772052 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1921,7 +1921,7 @@ if (empty($reshook)) { } if (!$error) { - $result = $object->cancel($idwarehouse); + $result = $object->cancel($user, $idwarehouse); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ae85c6a1b07..b21bd3c7c39 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -881,10 +881,11 @@ class Commande extends CommonOrder * Cancel an order * If stock is decremented on order validation, we must reincrement it * + * @param User $user User making action * @param int $idwarehouse Id warehouse to use for stock change. * @return int Return integer <0 if KO, >0 if OK */ - public function cancel($idwarehouse = -1) + public function cancel($user, $idwarehouse = -1) { global $user, $langs; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2b7d25e781b..32b35022b07 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -794,7 +794,7 @@ if (!$error && $massaction == 'cancelorders') { break; } else { // TODO We do not provide warehouse so no stock change here for the moment. - $result = $cmd->cancel(); + $result = $cmd->cancel($user); } if ($result < 0) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 68df094274a..9cd3c756fd0 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -549,7 +549,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $user->hasRight('expedition', 'supprimer')) { $also_update_stock = (GETPOST('alsoUpdateStock', 'alpha') ? 1 : 0); - $result = $object->cancel(0, (bool) $also_update_stock); + $result = $object->cancel($user, 0, (bool) $also_update_stock); if ($result > 0) { $result = $object->setStatut(-1); } else { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 224a76403da..fe3a76efc65 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1483,11 +1483,12 @@ class Expedition extends CommonObject /** * Cancel shipment. * - * @param int $notrigger Disable triggers - * @param bool $also_update_stock true if the stock should be increased back (false by default) - * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO + * @param User $user User making action + * @param int $notrigger Disable triggers + * @param bool $also_update_stock Use true if the stock should be increased back (false by default) + * @return int Return >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ - public function cancel($notrigger = 0, $also_update_stock = false) + public function cancel($user, $notrigger = 0, $also_update_stock = false) { global $conf, $langs, $user; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index dbf54b5928b..e80035d66ae 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1457,13 +1457,11 @@ class CommandeFournisseur extends CommonOrder * * @param User $user User making action * @param int $idwarehouse Id warehouse to use for stock change (not used for supplier orders). - * @return int >0 if Ok, <0 if Ko + * @return int Return >0 if OK, <0 if KO */ - public function Cancel($user, $idwarehouse = -1) + public function cancel($user, $idwarehouse = -1) { // phpcs:enable - global $langs, $conf; - $error = 0; //dol_syslog("CommandeFournisseur::Cancel");