mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-07 12:22:11 +00:00
Fixed up some stupid recursion on the Tree model template
This commit is contained in:
@@ -35,8 +35,6 @@ class PartCategoryTree(TreeSerializer):
|
||||
return reverse('part-index')
|
||||
|
||||
def get_items(self):
|
||||
|
||||
print("hello world")
|
||||
return PartCategory.objects.all().prefetch_related('parts', 'children')
|
||||
|
||||
|
||||
@@ -112,7 +110,9 @@ class PartList(generics.ListCreateAPIView):
|
||||
if cat_id:
|
||||
try:
|
||||
category = PartCategory.objects.get(pk=cat_id)
|
||||
parts_list = parts_list.filter(category__in=category.getUniqueChildren())
|
||||
cats = [category.id]
|
||||
cats += [cat for cat in category.getUniqueChildren()]
|
||||
parts_list = parts_list.filter(category__in=cats)
|
||||
except PartCategory.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
19
InvenTree/part/migrations/0008_auto_20190618_0042.py
Normal file
19
InvenTree/part/migrations/0008_auto_20190618_0042.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 2.2.2 on 2019-06-17 14:42
|
||||
|
||||
import InvenTree.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('part', '0007_auto_20190602_1944'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='partcategory',
|
||||
name='name',
|
||||
field=models.CharField(max_length=100, unique=True, validators=[InvenTree.validators.validate_tree_name]),
|
||||
),
|
||||
]
|
@@ -73,10 +73,12 @@ class PartCategory(InvenTreeTree):
|
||||
(including children of child categories)
|
||||
"""
|
||||
|
||||
cats = [self.id]
|
||||
|
||||
if cascade:
|
||||
query = Part.objects.filter(category__in=self.getUniqueChildren())
|
||||
else:
|
||||
query = Part.objects.filter(category=self)
|
||||
cats += [cat for cat in self.getUniqueChildren()]
|
||||
|
||||
query = Part.objects.filter(category__in=cats)
|
||||
|
||||
if active:
|
||||
query = query.filter(active=True)
|
||||
|
Reference in New Issue
Block a user