From 29c0448a2ed9bc78543b10b0da15778e3c3469c0 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 1 Nov 2018 15:41:58 +0100 Subject: [PATCH] Fix parent link was not removed on societe deletion #9106 --- htdocs/societe/class/societe.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2a488aacf44..0a49bb80f1b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1518,6 +1518,19 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); } } + + // Remove links to subsidiaries companies + if (! $error) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql.= " SET parent = NULL"; + $sql.= " WHERE parent = " . $id; + if (! $this->db->query($sql)) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } // Remove third party if (! $error)