mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-15 09:21:26 +00:00
Create a custom Manager class for the Part model
- Always perform prefetch_related calls
This commit is contained in:
@ -215,25 +215,6 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
if category_detail is not True:
|
||||
self.fields.pop('category_detail')
|
||||
|
||||
@staticmethod
|
||||
def prefetch_queryset(queryset):
|
||||
"""
|
||||
Prefetch related database tables,
|
||||
to reduce database hits.
|
||||
"""
|
||||
|
||||
return queryset.prefetch_related(
|
||||
'category',
|
||||
'category__parts',
|
||||
'category__parent',
|
||||
'stock_items',
|
||||
'bom_items',
|
||||
'builds',
|
||||
'supplier_parts',
|
||||
'supplier_parts__purchase_order_line_items',
|
||||
'supplier_parts__purchase_order_line_items__order',
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def annotate_queryset(queryset):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user