mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Don't serialize pricing
- Saves MANY queries and provides drastic speedup
This commit is contained in:
parent
18ff80312b
commit
d15b09a5f4
@ -1007,8 +1007,3 @@ class BomItem(models.Model):
|
|||||||
base_quantity = self.quantity * build_quantity
|
base_quantity = self.quantity * build_quantity
|
||||||
|
|
||||||
return base_quantity + self.get_overage_quantity(base_quantity)
|
return base_quantity + self.get_overage_quantity(base_quantity)
|
||||||
|
|
||||||
@property
|
|
||||||
def price_info(self):
|
|
||||||
""" Return the price for this item in the BOM """
|
|
||||||
return self.sub_part.get_price_info(self.quantity)
|
|
||||||
|
@ -34,7 +34,6 @@ class PartBriefSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||||
image_url = serializers.CharField(source='get_image_url', read_only=True)
|
image_url = serializers.CharField(source='get_image_url', read_only=True)
|
||||||
single_price_info = serializers.CharField(read_only=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Part
|
model = Part
|
||||||
@ -44,7 +43,6 @@ class PartBriefSerializer(serializers.ModelSerializer):
|
|||||||
'full_name',
|
'full_name',
|
||||||
'description',
|
'description',
|
||||||
'available_stock',
|
'available_stock',
|
||||||
'single_price_info',
|
|
||||||
'image_url',
|
'image_url',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -114,7 +112,6 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||||
sub_part_detail = PartBriefSerializer(source='sub_part', many=False, read_only=True)
|
sub_part_detail = PartBriefSerializer(source='sub_part', many=False, read_only=True)
|
||||||
price_info = serializers.CharField(read_only=True)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup_eager_loading(queryset):
|
def setup_eager_loading(queryset):
|
||||||
@ -132,7 +129,6 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
|||||||
'sub_part',
|
'sub_part',
|
||||||
'sub_part_detail',
|
'sub_part_detail',
|
||||||
'quantity',
|
'quantity',
|
||||||
'price_info',
|
|
||||||
'overage',
|
'overage',
|
||||||
'note',
|
'note',
|
||||||
]
|
]
|
||||||
|
@ -151,19 +151,6 @@ function loadBomTable(table, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
cols.push({
|
|
||||||
field: 'price_info',
|
|
||||||
title: 'Price',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
if (value) {
|
|
||||||
return value;
|
|
||||||
} else {
|
|
||||||
return "<span class='warning-msg'><i>No pricing information</i></span>";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Part notes
|
// Part notes
|
||||||
|
Loading…
Reference in New Issue
Block a user