mirror of https://github.com/interlegis/sapl.git
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							23 lines
						
					
					
						
							639 B
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							23 lines
						
					
					
						
							639 B
						
					
					
				| # Esse script foi feito para substituir a referência a Protocolo | |
| # em algum Documento, que antes era numero e ano, para uma FK | |
| 
 | |
| 
 | |
| from django.core.exceptions import ObjectDoesNotExist | |
| 
 | |
| from sapl.protocoloadm.models import DocumentoAdministrativo, Protocolo | |
| 
 | |
| 
 | |
| def substitui(): | |
|     for d in DocumentoAdministrativo.objects.all(): | |
|         if d.numero_protocolo: | |
|             try: | |
|                 d.protocolo = Protocolo.objects.get( | |
|                     ano=d.ano, | |
|                     numero=d.numero_protocolo) | |
|                 d.save() | |
|             except ObjectDoesNotExist: | |
|                 return | |
| 
 | |
| 
 | |
| if __name__ == '__main__': | |
|     substitui()
 | |
| 
 |