|  | @ -1118,38 +1118,41 @@ class DocumentoAnexadoEmLoteView(PermissionRequiredMixin, FilterView): | 
			
		
	
		
		
			
				
					|  |  |             return context |  |  |             return context | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         qr = self.request.GET.copy() |  |  |         qr = self.request.GET.copy() | 
			
		
	
		
		
			
				
					
					|  |  |         context['temp_object_list'] = context['object_list'].order_by( |  |  |         if not len(qr): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             'numero', '-ano' |  |  |             context['temp_object_list'] = [] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         ) |  |  |             context['object_list'] = [] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |         else: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         context['object_list'] = [] |  |  |             context['temp_object_list'] = context['object_list'].order_by( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         for obj in context['temp_object_list']: |  |  |             'numero', '-ano') | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             if not obj.pk == int(context['root_pk']): |  |  |             context['object_list'] = [] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 documento_principal = DocumentoAdministrativo.objects.get( |  |  |             for obj in context['temp_object_list']: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     id=context['root_pk']) |  |  |                 if not obj.pk == int(context['root_pk']): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 documento_anexado = obj |  |  |                     documento_principal = DocumentoAdministrativo.objects.get( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 is_anexado = Anexado.objects.filter(documento_principal=documento_principal, |  |  |                         id=context['root_pk']) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                                     documento_anexado=documento_anexado).exists() |  |  |                     documento_anexado = obj | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 if not is_anexado: |  |  |                     is_anexado = Anexado.objects.filter(documento_principal=documento_principal, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     ciclico = False |  |  |                                                         documento_anexado=documento_anexado).exists() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     anexados_anexado = Anexado.objects.filter( |  |  |                     if not is_anexado: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         documento_principal=documento_anexado) |  |  |                         ciclico = False | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |                         anexados_anexado = Anexado.objects.filter( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     while anexados_anexado and not ciclico: |  |  |                             documento_principal=documento_anexado) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         anexados = [] |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |                         while anexados_anexado and not ciclico: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         for anexo in anexados_anexado: |  |  |                             anexados = [] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                             if documento_principal == anexo.documento_anexado: |  |  |                             for anexo in anexados_anexado: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                 ciclico = True |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                             else: |  |  |                                 if documento_principal == anexo.documento_anexado: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                 for a in Anexado.objects.filter(documento_principal=anexo.documento_anexado): |  |  |                                     ciclico = True | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                                     anexados.append(a) |  |  |                                 else: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |                                     for a in Anexado.objects.filter(documento_principal=anexo.documento_anexado): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         anexados_anexado = anexados |  |  |                                         anexados.append(a) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     if not ciclico: |  |  |                             anexados_anexado = anexados | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                         context['object_list'].append(obj) |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                         if not ciclico: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             context['object_list'].append(obj) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |          | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         context['numero_res'] = len(context['object_list']) |  |  |         context['numero_res'] = len(context['object_list']) | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | 
 |