Fix deletion of shipment when there is batch record

This commit is contained in:
Laurent Destailleur 2021-09-15 13:29:19 +02:00
parent 77247ec43a
commit 724badb522
2 changed files with 4 additions and 8 deletions

View File

@ -1455,11 +1455,9 @@ class Expedition extends CommonObject
}
}
// delete batch expedition line
if (!$error && $conf->productbatch->enabled)
{
if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0)
{
// delete batch expedition line (we try deletion even if module not enabled in case of the module were enabled and disabled previously)
if (!$error) {
if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
}

View File

@ -153,10 +153,8 @@ class ExpeditionLineBatch extends CommonObject
*/
public static function deletefromexp($db, $id_expedition)
{
$id_expedition = (int) $id_expedition;
$sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element;
$sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".$id_expedition.")";
$sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".((int) $id_expedition).")";
dol_syslog(__METHOD__, LOG_DEBUG);
if ($db->query($sql))