From 8f5459660f9b677897a7219df76d692ac9713a74 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Fri, 6 Sep 2024 22:27:33 +0200 Subject: [PATCH] fix(edit-prod): Add assigned PT to queryset (#10843) --- dojo/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dojo/forms.py b/dojo/forms.py index 075c2eb0cb9..28c17082f6c 100644 --- a/dojo/forms.py +++ b/dojo/forms.py @@ -321,6 +321,8 @@ class ProductForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["prod_type"].queryset = get_authorized_product_types(Permissions.Product_Type_Add_Product) + if prod_type_id := getattr(kwargs.get("instance", Product()), "prod_type_id"): # we are editing existing instance + self.fields["prod_type"].queryset |= Product_Type.objects.filter(pk=prod_type_id) # even if user does not have permission for any other ProdType we need to add at least assign ProdType to make form submittable (otherwise empty list was here which generated invalid form) # if this product has findings being asynchronously updated, disable the sla config field if self.instance.async_updating: