diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 4bd6abb8a..c954413f5 100755 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -542,7 +542,6 @@ class ProtocoloDocumentoView(PermissionRequiredMixin, @transaction.atomic def form_valid(self, form): - import ipdb; ipdb.set_trace() protocolo = form.save(commit=False) username = self.request.user.username @@ -773,10 +772,22 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): data_fim__year__gte=timezone.now().year).first() data_inicio = legislatura.data_inicio data_fim = legislatura.data_fim + + data_inicio_utc = from_date_to_datetime_utc(data_inicio) + data_fim_utc = from_date_to_datetime_utc(data_fim) + numero = Protocolo.objects.filter( - data__gte=data_inicio, - data__lte=data_fim).aggregate( - Max('numero')) + Q(data__isnull=False, + data__gte=data_inicio, + data__lte=data_fim) | + Q(timestamp__isnull=False, + timestamp__gte=data_inicio_utc, + timestamp__lte=data_fim_utc) | + Q(timestamp_data_hora_manual__isnull=False, + timestamp_data_hora_manual__gte=data_inicio_utc, + timestamp_data_hora_manual__lte=data_fim_utc,)).\ + aggregate(Max('numero')) + elif numeracao == 'U': numero = Protocolo.objects.all().aggregate(Max('numero'))