2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Include pricing information in part supplier view

Also some CSS tweaks to secondary modal buttons
This commit is contained in:
Oliver Walters
2019-05-22 22:11:27 +10:00
parent 49425efef9
commit cd7bc6cce5
8 changed files with 55 additions and 8 deletions

View File

@ -81,7 +81,8 @@ class SupplierPartList(generics.ListCreateAPIView):
'part__stock_items',
'part__bom_items',
'part__builds',
'supplier')
'supplier',
'pricebreaks')
serializer_class = SupplierPartSerializer

View File

@ -239,6 +239,10 @@ class SupplierPart(models.Model):
""" Return the associated price breaks in the correct order """
return self.pricebreaks.order_by('quantity').all()
@property
def unit_pricing(self):
return self.get_price(1)
def get_price(self, quantity, moq=True, multiples=True):
""" Calculate the supplier price based on quantity price breaks.

View File

@ -62,6 +62,8 @@ class SupplierPartSerializer(serializers.ModelSerializer):
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
supplier_logo = serializers.CharField(source='supplier.get_image_url', read_only=True)
pricing = serializers.CharField(source='unit_pricing', read_only=True)
class Meta:
model = SupplierPart
fields = [
@ -76,6 +78,7 @@ class SupplierPartSerializer(serializers.ModelSerializer):
'manufacturer',
'MPN',
'URL',
'pricing',
]