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.
This commit is contained in:
ldestailleur 2025-09-03 16:08:00 +02:00
parent cc6f43493c
commit 0255512c1c
7 changed files with 13 additions and 12 deletions

View file

@ -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.

View file

@ -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');

View file

@ -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;

View file

@ -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) {

View file

@ -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 {

View file

@ -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;

View file

@ -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");