From edf27c97f92900b6df63480730bb443e9ed3b36c Mon Sep 17 00:00:00 2001 From: Jyrki Launonen Date: Sun, 21 Jul 2024 14:35:36 +0300 Subject: [PATCH] Fix receipt box item removal form validation Fixes commit 2524a1afd0076e38d9794ada9b66bca63ef56311 --- kirppu/forms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kirppu/forms.py b/kirppu/forms.py index 2ad1e43..625d074 100644 --- a/kirppu/forms.py +++ b/kirppu/forms.py @@ -316,7 +316,8 @@ def clean_receipt(self): def clean_code(self): data = self.cleaned_data["code"] if box_match := re.match(r"box[_ -]?(\d+)$", data): - if not Box.objects.filter(pk=int(box_match[1])).exists(): + # Indefinite check: there may be multiple Box objects with same box_number, across different Events. + if not Box.objects.filter(box_number=int(box_match[1])).exists(): raise forms.ValidationError("Box {} not found".format(box_match[1])) return data if not Item.is_item_barcode(data):