mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-15 09:21:26 +00:00
Add a query param `?include_pricing' to the BomItem API
- Set this to false to disable pricing info in BOM - Drastic reduction in query speed
This commit is contained in:
@ -419,6 +419,7 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
|
||||
part_detail = kwargs.pop('part_detail', False)
|
||||
sub_part_detail = kwargs.pop('sub_part_detail', False)
|
||||
include_pricing = kwargs.pop('include_pricing', False)
|
||||
|
||||
super(BomItemSerializer, self).__init__(*args, **kwargs)
|
||||
|
||||
@ -428,6 +429,14 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
if sub_part_detail is not True:
|
||||
self.fields.pop('sub_part_detail')
|
||||
|
||||
if not include_pricing:
|
||||
# Remove all pricing related fields
|
||||
self.fields.pop('price_range')
|
||||
self.fields.pop('purchase_price_min')
|
||||
self.fields.pop('purchase_price_max')
|
||||
self.fields.pop('purchase_price_avg')
|
||||
self.fields.pop('purchase_price_range')
|
||||
|
||||
@staticmethod
|
||||
def setup_eager_loading(queryset):
|
||||
queryset = queryset.prefetch_related('part')
|
||||
|
Reference in New Issue
Block a user