From 544c231ecf005d1b379a65ec3610ca524d7249ef Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 28 Jan 2016 17:32:39 -0200 Subject: [PATCH] Fix #176 --- protocoloadm/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 14280c374..87f0684b9 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -492,6 +492,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 @@ -618,6 +622,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