annee_courante = datetime.datetime.now().year
if 'implantation_id' in params and params.get('implantation_id') is not u"":
implantation_id = params.get('implantation_id')
- objects = rh.ValeurPoint.objects.filter(implantation=implantation_id, annee__in=(annee_courante-1, annee_courante)).order_by("-annee")
+ preselectionne = rh.ValeurPoint.objects.filter(implantation=implantation_id, annee__in=(annee_courante,)).order_by("-annee")
+ for o in preselectionne:
+ data.append({'id' : o.id, 'label' : o.__unicode__(), 'devise' : o.get_tauxchange_courant().devise.id, 'suggestion' : True})
else:
- objects = rh.ValeurPoint.objects.filter(annee__in=(annee_courante-1, annee_courante)).order_by("-annee")
- for o in objects:
- data.append({'id' : o.id, 'label' : o.__unicode__(), })
+ preselectionne = rh.ValeurPoint.objects.none()
+
+ liste_complete = rh.ValeurPoint.objects.filter(annee__in=(annee_courante,)).order_by("-annee")
+ for o in liste_complete.exclude(id__in=[p.id for p in preselectionne]):
+ data.append({'id' : o.id, 'label' : o.__unicode__(), 'devise' : o.get_tauxchange_courant().devise.id, 'suggestion' : False})
return HttpResponse(dumps(data))
################################################################################
var options = "";
$.each(data, function() {
- options += '<option value="' + this.id + '">' + this.label + '</option>';
+ var suggestion = "";
+ if (this.suggestion) {
+ suggestion = " style='font-weight: bold; color: black;' "
+ }
+ options += '<option ' + suggestion + ' value="' + this.id + '">' + this.label + '</option>';
});
$("#id_valeur_point_min").html(options);