From 93477c102f725a449cc912dbc8b0ba168c9926e4 Mon Sep 17 00:00:00 2001
From: John <john.botella@atm-consulting.fr>
Date: Mon, 26 Jun 2017 15:44:04 +0200
Subject: [PATCH] FIX delete linked element on facture rec

---
 htdocs/compta/facture/class/facture-rec.class.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index ef23a30b878..e39a4a7b994 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -475,7 +475,13 @@ class FactureRec extends CommonInvoice
 		{
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid;
 			dol_syslog($sql);
-			if (! $this->db->query($sql))
+			if ($this->db->query($sql))
+			{
+				// Delete linked object
+				$res = $this->deleteObjectLinked();
+				if ($res < 0) $error=-3;
+			}
+			else 
 			{
 				$this->error=$this->db->lasterror();
 				$error=-1;
-- 
GitLab