Skip to content

Commit 9286f21

Browse files
authored
fix(edit-prod): Add assigned PT to queryset (#10843)
1 parent a459849 commit 9286f21

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

dojo/forms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ class ProductForm(forms.ModelForm):
321321
def __init__(self, *args, **kwargs):
322322
super().__init__(*args, **kwargs)
323323
self.fields["prod_type"].queryset = get_authorized_product_types(Permissions.Product_Type_Add_Product)
324+
if prod_type_id := getattr(kwargs.get("instance", Product()), "prod_type_id"): # we are editing existing instance
325+
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)
324326

325327
# if this product has findings being asynchronously updated, disable the sla config field
326328
if self.instance.async_updating:

0 commit comments

Comments
 (0)