diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index 6a5d4680..677e0fa8 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -222,8 +222,7 @@ class Transaction(PolymorphicModel): self.destination_alias = str(self.destination) if self.source.pk == self.destination.pk: - # When source == destination, no money is transferred - super().save(*args, **kwargs) + # When source == destination, no money is transferred and no transaction is created return self.log("Saving") diff --git a/static/js/transfer.js b/static/js/transfer.js index db467a31..2ee879dc 100644 --- a/static/js/transfer.js +++ b/static/js/transfer.js @@ -246,6 +246,13 @@ $("#btn_transfer").click(function() { // We copy the arrays to ensure that transactions are well-processed even if the form is reset [...sources_notes_display].forEach(function (source) { [...dests_notes_display].forEach(function (dest) { + if (source.note.id === dest.note.id) { + addMsg("Attention : la transaction de " + pretty_money(amount) + " de la note " + source.name + + " vers la note " + dest.name + " n'a pas été faite car il s'agit de la même note au départ" + + " et à l'arrivée.","warning", 10000); + return; + } + $.post("/api/note/transaction/transaction/", { "csrfmiddlewaretoken": CSRF_TOKEN,