From d45c57a69c0a8eae15db7d2f9d402f5d63f14da9 Mon Sep 17 00:00:00 2001 From: Eliseu Egewarth Date: Tue, 8 Aug 2017 10:39:44 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20erro=20de=20l=C3=B3gica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eliseu Egewarth --- sapl/protocoloadm/forms.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index 637c262f5..a3b71e998 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -234,15 +234,13 @@ class AnularProcoloAdmForm(ModelForm): raise forms.ValidationError( _("Protocolo %s/%s não existe" % (numero, ano))) exists = False - documentos_vinculados = [] if protocolo.tipo_materia: - documentos_vinculados = MateriaLegislativa.objects.filter( - numero_protocolo=protocolo.numero, ano=protocolo.ano) + exists = MateriaLegislativa.objects.filter( + numero_protocolo=protocolo.numero, ano=protocolo.ano).exists() elif protocolo.tipo_documento: - documentos_vinculados = protocolo.documentoadministrativo_set.all( - ).order_by('-ano', '-numero') + exists = protocolo.documentoadministrativo_set.all( + ).order_by('-ano', '-numero').exists() - exists = documentos_vinculados.exists() if exists: raise forms.ValidationError( _("Protocolo %s/%s não pode ser removido pois existem"