From 6a5a5f1284f6631c936c7dd8c7dbb9b6b6f1c92a Mon Sep 17 00:00:00 2001 From: AndreSouto Date: Tue, 6 Nov 2018 15:16:26 -0200 Subject: [PATCH] Fix Chamado 493294 (osTicket) (#2345) * Fix Chamado #493294 * Troca de .get por .filter * Fix Chamado #493294 * Fix Chamado #493294 --- sapl/materia/models.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/sapl/materia/models.py b/sapl/materia/models.py index b3dfc1671..1f2667780 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import Group from django.contrib.contenttypes.fields import GenericRelation from django.contrib.contenttypes.models import ContentType -from django.core.exceptions import ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist,MultipleObjectsReturned from django.db import models from django.db.models.functions import Concat from django.template import defaultfilters @@ -261,18 +261,15 @@ class MateriaLegislativa(models.Model): ''' from sapl.protocoloadm.models import Protocolo if self.ano and self.numero_protocolo: - try: - protocolo = Protocolo.objects.get( - ano=self.ano, - numero=self.numero_protocolo) - if protocolo.timestamp: - return protocolo.timestamp.date() - else: - return protocolo.data - except ObjectDoesNotExist: - pass - - return '' + protocolo = Protocolo.objects.filter( + ano=self.ano, + numero=self.numero_protocolo) + if protocolo.first().timestamp: + return protocolo.first().timestamp.date() + else: + return protocolo.data + else: + return '' def delete(self, using=None, keep_parents=False): if self.texto_original: