diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 732ae2310..75638c7de 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -486,6 +486,10 @@ class ProtocoloDocumentoView(FormMixin, GenericView): ano=date.today().year).aggregate(Max('numero')) else: numeracao = Protocolo.objects.all().aggregate(Max('numero')) + + if numeracao is None: + numeracao['numero__max'] = 0 + protocolo = Protocolo() protocolo.numero = numeracao['numero__max'] + 1 protocolo.ano = datetime.now().year @@ -609,6 +613,9 @@ class ProtocoloMateriaView(FormMixin, GenericView): else: numeracao = Protocolo.objects.all().aggregate(Max('numero')) + if numeracao is None: + numero['numero__max'] = 0 + protocolo = Protocolo() protocolo.numero = numeracao['numero__max'] + 1