mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-16 09:18:10 +00:00
[refactor] Build list (#11010)
- Prefetch project_code - Annotate parameter data
This commit is contained in:
@@ -317,14 +317,15 @@ class BuildMixin:
|
||||
"""Return the queryset for the Build API endpoints."""
|
||||
queryset = super().get_queryset()
|
||||
|
||||
queryset = build.serializers.BuildSerializer.annotate_queryset(queryset)
|
||||
|
||||
queryset = queryset.prefetch_related(
|
||||
'responsible',
|
||||
'issued_by',
|
||||
'build_lines',
|
||||
'build_lines__bom_item',
|
||||
'build_lines__build',
|
||||
'part',
|
||||
'part__pricing_data',
|
||||
'project_code',
|
||||
)
|
||||
|
||||
return queryset
|
||||
@@ -384,14 +385,6 @@ class BuildList(
|
||||
'priority',
|
||||
]
|
||||
|
||||
def get_queryset(self):
|
||||
"""Override the queryset filtering, as some of the fields don't natively play nicely with DRF."""
|
||||
queryset = super().get_queryset().select_related('part')
|
||||
|
||||
queryset = build.serializers.BuildSerializer.annotate_queryset(queryset)
|
||||
|
||||
return queryset
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
"""Add extra context information to the endpoint serializer."""
|
||||
kwargs['create'] = True
|
||||
|
||||
@@ -192,6 +192,8 @@ class BuildSerializer(
|
||||
)
|
||||
)
|
||||
|
||||
queryset = Build.annotate_parameters(queryset)
|
||||
|
||||
return queryset
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user