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):