From 5803060caf09ef3aca62a98cea0d219234ef579c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 14:43:11 +0100 Subject: [PATCH 1/3] Fix shipment delete --- htdocs/expedition/class/expedition.class.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8ef7be75f52..dd0022b09dc 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1403,6 +1403,9 @@ class Expedition extends CommonObject $langs->load("agenda"); + // we try deletion of batch line even if module batch not enabled in case of the module were enabled and disabled previously + $shipmentlinebatch = new ExpeditionLineBatch($this->db); + // Loop on each product line to add a stock movement $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid as expeditiondet_id"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; @@ -1422,12 +1425,9 @@ class Expedition extends CommonObject // we do not log origin because it will be deleted $mouvS->origin = null; // get lot/serial - $lotArray = null; - if ($conf->productbatch->enabled) { - $lotArray = ExpeditionLineBatch::fetchAll($this->db, $obj->expeditiondet_id); - if (!is_array($lotArray)) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); - } + $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id); + if (!is_array($lotArray)) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (empty($lotArray)) { // no lot/serial @@ -1458,9 +1458,8 @@ class Expedition extends CommonObject } } - // delete batch expedition line (we try deletion even if module not enabled in case of the module were enabled and disabled previously) + // delete batch expedition line if (!$error) { - $shipmentlinebatch = ExpeditionLineBatch($this->db); if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } From 7018fe9530e75a1eb13e5d4eb2f28f076cb3c60c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 16:48:39 +0100 Subject: [PATCH 2/3] Update changelog ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 00962b10419..023b70ec79e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed From 16c4dec6dac82cc1f672b11e6c3f2de82626f056 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 17:36:00 +0100 Subject: [PATCH 3/3] Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 023b70ec79e..9fa65871f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php * ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed