diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb index 37c8180f9..8d9fdfca4 100644 --- a/app/models/attestation_template.rb +++ b/app/models/attestation_template.rb @@ -87,13 +87,13 @@ class AttestationTemplate < ApplicationRecord end def unspecified_champs_for_dossier(dossier) - champs_by_stable_id = dossier.champs_for_revision(root: true).index_by { "tdc#{_1.stable_id}" } + types_de_champ_by_tag_id = dossier.revision.types_de_champ.index_by { "tdc#{_1.stable_id}" } used_tags.filter_map do |used_tag| - corresponding_champ = champs_by_stable_id[used_tag] + corresponding_type_de_champ = types_de_champ_by_tag_id[used_tag] - if corresponding_champ && corresponding_champ.blank? - corresponding_champ + if corresponding_type_de_champ && dossier.project_champ(corresponding_type_de_champ, nil).blank? + corresponding_type_de_champ end end end