Revised the txn_sort view so that the reorder will not pass the save() method and induce complex reorder in the accounting application.
This commit is contained in:
		| @@ -940,9 +940,8 @@ def txn_sort(request, date): | |||||||
|         keys.sort(key=lambda x: int(post[x])) |         keys.sort(key=lambda x: int(post[x])) | ||||||
|         for i in range(len(keys)): |         for i in range(len(keys)): | ||||||
|             post[keys[i]] = i + 1 |             post[keys[i]] = i + 1 | ||||||
|         for txn in transactions: |         modified = [[x, post[F"transaction-{x.pk}-ord"]] for x in transactions | ||||||
|             txn.ord = post[F"transaction-{txn.pk}-ord"] |                     if x.ord != post[F"transaction-{x.pk}-ord"]] | ||||||
|         modified = [x for x in transactions if x.is_dirty()] |  | ||||||
|  |  | ||||||
|         if len(modified) == 0: |         if len(modified) == 0: | ||||||
|             messages.success(request, gettext_noop( |             messages.success(request, gettext_noop( | ||||||
| @@ -950,8 +949,8 @@ def txn_sort(request, date): | |||||||
|             return redirect(request.GET.get("r") or reverse("accounting:home")) |             return redirect(request.GET.get("r") or reverse("accounting:home")) | ||||||
|  |  | ||||||
|         with transaction.atomic(): |         with transaction.atomic(): | ||||||
|             for txn in modified: |             for x in modified: | ||||||
|                 txn.save() |                 Transaction.objects.filter(pk=x[0].pk).update(ord=x[1]) | ||||||
|         messages.success(request, gettext_noop( |         messages.success(request, gettext_noop( | ||||||
|             "The transaction orders were saved successfully.")) |             "The transaction orders were saved successfully.")) | ||||||
|         return redirect(request.GET.get("r") or reverse("accounting:home")) |         return redirect(request.GET.get("r") or reverse("accounting:home")) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user