From be46b2062ee29fe57181170b21a5241080f895ab Mon Sep 17 00:00:00 2001 From: Marc Guenneugues Date: Thu, 23 Apr 2020 17:51:06 +0200 Subject: [PATCH] Clean line extrafields when deleting order --- htdocs/commande/class/commande.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 52dfde785a4..54506a4a816 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3396,6 +3396,19 @@ class Commande extends CommonOrder $error++; } + if (!$error) + { + // Delete extrafields of order details + $main = MAIN_DB_PREFIX . 'commandedet'; + $ef = $main . "_extrafields"; + $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = " . $this->id . ")"; + if (!$this->db->query($sql)) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + if (!$error) { // Delete order details