From 7cae0ceab8f54d715b52b790b3273e3f7b6c34fe Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 8 Feb 2024 13:07:54 +0100 Subject: [PATCH] Fix migration of old hide_without_voucher products --- src/pretix/control/views/item.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pretix/control/views/item.py b/src/pretix/control/views/item.py index fdbc046b2c..7732805acc 100644 --- a/src/pretix/control/views/item.py +++ b/src/pretix/control/views/item.py @@ -1483,6 +1483,12 @@ class ItemUpdateGeneral(ItemDetailMixin, EventPermissionRequiredMixin, MetaDataE messages.error(self.request, _('We could not save your changes. See below for details.')) return super().form_invalid(form) + def get_object(self, queryset=None) -> Item: + o = super().get_object(queryset) + if o.hide_without_voucher: + o.require_voucher = True + return o + def get_context_data(self, **kwargs): ctx = super().get_context_data() ctx['plugin_forms'] = self.plugin_forms @@ -1493,8 +1499,6 @@ class ItemUpdateGeneral(ItemDetailMixin, EventPermissionRequiredMixin, MetaDataE messages.info(self.request, _("You disabled this item, but it is still part of a product bundle. " "Your participants won't be able to buy the bundle unless you remove this " "item from it.")) - if ctx['item'].hide_without_voucher: - ctx['item'].require_voucher = True ctx['sales_channels'] = get_all_sales_channels() return ctx