From 5f9c2d9f8c21218207242207e2bdc12b29aecc84 Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Tue, 26 Jun 2018 12:54:47 -0300 Subject: [PATCH] Fix #2042 (#2045) --- sapl/norma/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 650442676..9c98e783e 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -204,9 +204,9 @@ def recuperar_numero_norma(request): param = {'tipo': tipo} param['ano'] = ano if ano else timezone.now().year - - norma = NormaJuridica.objects.filter(**param).order_by( - 'tipo', 'ano', 'numero').values_list('numero', 'ano').last() + norma = NormaJuridica.objects.filter(**param).extra( + {'numero_id': "CAST(numero as INTEGER)"}).order_by( + 'tipo', 'ano','numero_id').values_list('numero', 'ano').last() if norma: response = JsonResponse({'numero': int(norma[0]) + 1, 'ano': norma[1]})