From 27e09aea24b46dfb6068ce39dd77f89ea0e62e14 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Tue, 8 Nov 2016 14:17:58 -0200 Subject: [PATCH] =?UTF-8?q?Muda=20migra=C3=A7=C3=A3o=20de=20campo=20manyto?= =?UTF-8?q?many?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 26f786004..aed78fd88 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -17,7 +17,7 @@ from sapl.comissoes.models import Composicao, Participacao from sapl.materia.models import (Proposicao, StatusTramitacao, TipoDocumento, TipoMateriaLegislativa, TipoProposicao, Tramitacao) -from sapl.norma.models import AssuntoNormaRelationship, NormaJuridica +from sapl.norma.models import AssuntoNorma, NormaJuridica from sapl.parlamentares.models import Parlamentar from sapl.protocoloadm.models import StatusTramitacaoAdministrativo from sapl.sessao.models import ExpedienteMateria, OrdemDia, SessaoPlenaria @@ -526,12 +526,9 @@ def adjust_normajuridica_antes_salvar(new, old): def adjust_normajuridica_depois_salvar(new, old): # Ajusta relação M2M - lista_ids_assunto = old.cod_assunto.split(',') - for id_assunto in lista_ids_assunto: - relacao = AssuntoNormaRelationship() - relacao.assunto_id = int(id_assunto) - relacao.norma_id = new.pk - relacao.save() + lista_pks_assunto = old.cod_assunto.split(',') + for pk_assunto in lista_pks_assunto: + new.assuntos.add(AssuntoNorma.objects.get(pk=pk_assunto)) def adjust_autor(new, old):