mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-09 03:03:41 +00:00
- Prevent duplicate parameters
- Closes https://github.com/inventree/InvenTree/issues/11798
(cherry picked from commit 75942fbedf)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
committed by
GitHub
parent
a4115cdd16
commit
7b63aa900c
@@ -2478,6 +2478,7 @@ class Part(
|
|||||||
category__in=categories
|
category__in=categories
|
||||||
).order_by('-category__level')
|
).order_by('-category__level')
|
||||||
|
|
||||||
|
template_ids = set()
|
||||||
parameters = []
|
parameters = []
|
||||||
content_type = ContentType.objects.get_for_model(Part)
|
content_type = ContentType.objects.get_for_model(Part)
|
||||||
|
|
||||||
@@ -2488,6 +2489,12 @@ class Part(
|
|||||||
).exists():
|
).exists():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Ensure we do not create duplicate parameters if multiple categories have the same template
|
||||||
|
if category_template.template.pk in template_ids:
|
||||||
|
continue
|
||||||
|
|
||||||
|
template_ids.add(category_template.template.pk)
|
||||||
|
|
||||||
parameters.append(
|
parameters.append(
|
||||||
Parameter(
|
Parameter(
|
||||||
template=category_template.template,
|
template=category_template.template,
|
||||||
@@ -2497,7 +2504,6 @@ class Part(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(parameters) > 0:
|
|
||||||
Parameter.objects.bulk_create(parameters)
|
Parameter.objects.bulk_create(parameters)
|
||||||
|
|
||||||
def getTestTemplates(
|
def getTestTemplates(
|
||||||
|
|||||||
Reference in New Issue
Block a user