From 208bf2545fd1519c639097db6241f793a78a9adf Mon Sep 17 00:00:00 2001
From: fmarcet <fmarcet@2byte.es>
Date: Thu, 26 Nov 2015 17:14:03 +0100
Subject: [PATCH] Fix: Bug when idprof is mandatory on thrid creation and we
 use multicompany

---
 htdocs/societe/class/societe.class.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 8e5622cde77..351b813959b 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2348,7 +2348,7 @@ class Societe extends CommonObject
         }
 
          //Verify duplicate entries
-        $sql  = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."'";
+        $sql  = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe',1).")";
         if($socid) $sql .= " AND rowid <> ".$socid;
         $resql = $this->db->query($sql);
         if ($resql)
-- 
GitLab