2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-16 09:18:10 +00:00

Revert change to parameters property

This commit is contained in:
Oliver Walters
2025-11-24 23:56:01 +00:00
parent b6c38b91e1
commit 6e1292aa62

View File

@@ -6,7 +6,7 @@ from string import Formatter
from typing import Any, Optional
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import QuerySet
@@ -501,7 +501,13 @@ class InvenTreeParameterMixin(InvenTreePermissionCheckMixin):
and provides the following methods:
"""
parameters = GenericRelation('common.Parameter', related_query_name='+')
@property
def parameters(self) -> QuerySet:
"""Return a QuerySet containing all the Parameter instances for this model."""
from common.models import Parameter
content_type = ContentType.objects.get_for_model(self.__class__)
return Parameter.objects.filter(model_type=content_type, model_id=self.pk)
def delete(self, *args, **kwargs):
"""Handle the deletion of a model instance.