diff --git a/app/models/modules.py b/app/models/modules.py
index 7c7a38203e47f048bb8ad4095d3b08811da57058..6adba8d5089f9ee407a2271be0ec7ac00c7be7e2 100644
--- a/app/models/modules.py
+++ b/app/models/modules.py
@@ -228,9 +228,11 @@ class Module(models.ScoDocModel):
formation = data.get("formation")
if formation is None or not isinstance(formation, Formation):
raise ScoValueError("Module.create_from_dict: formation missing")
- else: # check ue_id
- formation = UniteEns.get_ue(data["ue_id"])
- # formation = Formation.get_formation(data["formation_id"])
+ else:
+ formation = Formation.get_formation(data["formation_id"])
+ #
+ if ue.formation_id != formation.id:
+ raise ScoValueError("Module.create_from_dict: UE not in formation")
# refuse de créer un module APC avec semestres semestre du module != semestre de l'UE
if formation.is_apc():
if int(data.get("semestre_id", 1)) != ue.semestre_idx: