use more abstract definitions

This commit is contained in:
Matthias 2022-03-11 00:25:58 +01:00
parent 0a1961bc31
commit d086f09771
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -40,7 +40,19 @@ import stock.serializers
from users.serializers import OwnerSerializer
class POSerializer(ReferenceIndexingSerializerMixin, InvenTreeModelSerializer):
class AbstractOrderSerializer:
"""
Abstract field definitions for OrderSerializers
"""
total_price = InvenTreeMoneySerializer(
source='get_total_price',
allow_null=True,
read_only=True,
)
total_price_string = serializers.CharField(source='get_total_price', read_only=True)
""" Serializer for a PurchaseOrder object """
def __init__(self, *args, **kwargs):
@ -467,7 +479,7 @@ class POAttachmentSerializer(InvenTreeAttachmentSerializer):
]
class SalesOrderSerializer(ReferenceIndexingSerializerMixin, InvenTreeModelSerializer):
class SalesOrderSerializer(AbstractOrderSerializer, ReferenceIndexingSerializerMixin, InvenTreeModelSerializer):
"""
Serializers for the SalesOrder object
"""
@ -515,14 +527,6 @@ class SalesOrderSerializer(ReferenceIndexingSerializerMixin, InvenTreeModelSeria
reference = serializers.CharField(required=True)
total_price = InvenTreeMoneySerializer(
source='get_total_price',
allow_null=True,
read_only=True,
)
total_price_string = serializers.CharField(source='get_total_price', read_only=True)
class Meta:
model = order.models.SalesOrder