Index: controlies/trunk/applications/controlies/modules/Thinclients.py
===================================================================
--- controlies/trunk/applications/controlies/modules/Thinclients.py	(revision 213)
+++ controlies/trunk/applications/controlies/modules/Thinclients.py	(revision 214)
@@ -150,9 +150,10 @@
 		('dhcpStatements', ['filename "/var/lib/tftpboot/ltsp/i386/pxelinux.0"'] ), 
 		('dhcpHWAddress', ['ethernet ' + self.mac] )
 		]		
-		freeGroup = self.getFreeGroup()
-		print freeGroup
-		self.ldap.add("cn="+self.name +",cn="+self.group+",cn=THINCLIENTS,cn=DHCP Config", attr)
+		group = self.getFreeGroup()
+
+		print group["freeGroup"]
+		self.ldap.add("cn="+self.name +",cn="+group["freeGroup"]+",cn=THINCLIENTS,cn=DHCP Config", attr)
             
 		return "OK"
         
@@ -164,7 +165,9 @@
         return "OK"
 
     def delete(self):
-        self.ldap.delete('cn='+ self.name +',cn=group1,cn=THINCLIENTS,cn=DHCP Config')
+        group = self.getGroup()
+        if group != "noGroup":
+            self.ldap.delete('cn='+ self.name +',cn='+group+',cn=THINCLIENTS,cn=DHCP Config')
 
         return "OK"     
        
@@ -197,10 +200,19 @@
         return self.mac   
 
 
+    def getGroup (self):
+        groups = self.getThinclientGroups()        
+        for g in groups['groups']:
+            search = self.ldap.search("cn="+g+",cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn"])
+            if len(search) == 1:
+			    return g
+            
+        return "noGroup"
+
+
     def getThinclientGroups (self):
         groups = []
         search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=group*",["cn"])
-        
         for g in search:
             groups.append (g[0][1]["cn"][0])
             
@@ -207,21 +219,20 @@
         return { "groups":groups }
 
 
+    def groupOverflow(self,group,overflow):
+        search = self.ldap.search("cn="+group+",cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn"])
+        print len(search)        
+        if len(search)-2 >= overflow:
+            return True
+                
+        return False
+        
+
     def getFreeGroup (self):
         freeGroup = []
         groups = self.getThinclientGroups()        
-        
-        for g in groups:
+        for g in groups['groups']:
             if not self.groupOverflow(g,300):
-				return { "freeGroup":freeGroup }
+				return { "freeGroup":g }
 
-        return { "freeGroup" : freeGroup }
-
-
-    def groupOverflow(self,group,overflow):
-        if self.type_host == 'thinclient':
-            search = self.ldap.search("cn="+group+",cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn"])
-            if len(search)-2 >= overflow:
-                return True
-                
-        return False
+        return { "freeGroup" : 'noFreeGroup' }
Index: controlies/trunk/applications/controlies/views/thinclients/index.html
===================================================================
--- controlies/trunk/applications/controlies/views/thinclients/index.html	(revision 213)
+++ controlies/trunk/applications/controlies/views/thinclients/index.html	(revision 214)
@@ -195,8 +195,8 @@
     
     function deleteRecord(){
         
-            var uid = rowSelected();
-            if(uid==false)
+            var name = rowSelected();
+            if(name==false)
                 return false;
         
             jQuery( "#dialog-confirm" ).dialog({
@@ -206,7 +206,7 @@
                 modal: true,
                 buttons: {
                     "Borrar": function() {
-                        jQuery.post("call/json/delete","user="+uid, function(data){
+                        jQuery.post("call/json/delete",{host:name}, function(data){
                             jQuery("#dialog-confirm").dialog( "close" );
                             jQuery("#list").trigger("reloadGrid");
                         });
Index: controlies/trunk/applications/controlies/controllers/thinclients.py
===================================================================
--- controlies/trunk/applications/controlies/controllers/thinclients.py	(revision 213)
+++ controlies/trunk/applications/controlies/controllers/thinclients.py	(revision 214)
@@ -55,8 +55,8 @@
 @auth.requires_login()    
 def delete():
     l=conecta()
-    h = Hosts(l,request.vars['cn'],"","",request.vars['type_host'])
-    response=h.process(request.vars['action']  )
+    h = Thinclients(l,request.vars['host'],"")
+    response=h.process("delete")
     l.close()
     return dict(response=response)
 
