From d15b09a5f4eddccc1f69146adcea3a39bb813fa1 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 20 May 2019 23:03:19 +1000 Subject: [PATCH] Don't serialize pricing - Saves MANY queries and provides drastic speedup --- InvenTree/part/models.py | 5 ----- InvenTree/part/serializers.py | 4 ---- InvenTree/static/script/inventree/bom.js | 13 ------------- 3 files changed, 22 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 6d6f02f6a3..19b2543da2 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1007,8 +1007,3 @@ class BomItem(models.Model): base_quantity = self.quantity * build_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) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index e91a3c6589..d8da916cb2 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -34,7 +34,6 @@ class PartBriefSerializer(serializers.ModelSerializer): url = serializers.CharField(source='get_absolute_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: model = Part @@ -44,7 +43,6 @@ class PartBriefSerializer(serializers.ModelSerializer): 'full_name', 'description', 'available_stock', - 'single_price_info', 'image_url', ] @@ -114,7 +112,6 @@ class BomItemSerializer(InvenTreeModelSerializer): part_detail = PartBriefSerializer(source='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 def setup_eager_loading(queryset): @@ -132,7 +129,6 @@ class BomItemSerializer(InvenTreeModelSerializer): 'sub_part', 'sub_part_detail', 'quantity', - 'price_info', 'overage', 'note', ] diff --git a/InvenTree/static/script/inventree/bom.js b/InvenTree/static/script/inventree/bom.js index 6e00eabe67..6ff81de4fc 100644 --- a/InvenTree/static/script/inventree/bom.js +++ b/InvenTree/static/script/inventree/bom.js @@ -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 "No pricing information"; - } - }, - }); } // Part notes