Fix: les transferts apparaissent dans l'historique perso

This commit is contained in:
Ludovic Stephan 2020-04-23 13:13:31 +02:00
parent 2aa06d2954
commit 9eebc7fb22

View file

@ -1404,8 +1404,8 @@ def history_json(request):
to_date = request.POST.get("to", None)
checkouts = request.POST.getlist("checkouts[]", None)
accounts = request.POST.getlist("accounts[]", None)
transfers_only = request.POST.get("transfersonly", None)
opes_only = request.POST.get("opesonly", None)
transfers_only = request.POST.get("transfersonly", False)
opes_only = request.POST.get("opesonly", False)
# Construction de la requête (sur les transferts) pour le prefetch
@ -1416,7 +1416,7 @@ def history_json(request):
# Le check sur les comptes est dans le prefetch pour les transferts
if accounts:
transfer_queryset_prefetch = transfer_queryset_prefetch.filter(
Q(from_acc__trigramme__in=accounts) | Q(to_acc__trigramme__in=accounts)
Q(from_acc__in=accounts) | Q(to_acc__in=accounts)
)
if not request.user.has_perm("kfet.is_team"):
@ -1458,14 +1458,14 @@ def history_json(request):
opegroups = opegroups.filter(at__lt=to_date)
transfergroups = transfergroups.filter(at__lt=to_date)
if checkouts:
opegroups = opegroups.filter(checkout_id__in=checkouts)
opegroups = opegroups.filter(checkout__in=checkouts)
transfergroups = TransferGroup.objects.none()
if transfers_only:
opegroups = OperationGroup.objects.none()
if opes_only:
transfergroups = TransferGroup.objects.none()
if accounts:
opegroups = opegroups.filter(on_acc_id__in=accounts)
opegroups = opegroups.filter(on_acc__in=accounts)
# Un non-membre de l'équipe n'a que accès à son historique
if not request.user.has_perm("kfet.is_team"):
opegroups = opegroups.filter(on_acc=request.user.profile.account_kfet)