Fix for titulaire antérieur
[auf_rh_dae.git] / project / dae / views.py
index 7277d8b..f5ae987 100644 (file)
@@ -596,12 +596,16 @@ def embauche(request, key=None, dossier_id=None):
         cmp_form.fields['implantation'].queryset = imp_qs
 
     # Comment out for now.
-    # if dossier and dossier.poste:
-    #     dossier_form.fields['employe_anterieur'].queryset = (
-    #         dossier_form.fields['employe_anterieur'].queryset.filter(
-    #             rh_dossiers__poste=dossier.poste,
-    #             ).distinct()
-    #         )
+    try:
+        rh_poste = poste.id_rh
+    except rh.Poste.DoesNotExist:
+        rh_poste = None
+    if dossier and rh_poste:
+        dossier_form.fields['employe_anterieur'].queryset = (
+            dossier_form.fields['employe_anterieur'].queryset.filter(
+                rh_dossiers__poste__pk=rh_poste.pk,
+                ).distinct()
+            )
 
     c = {
         'type_remun': filtered_type_remun(),