diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 37437c97e3..2868af07c8 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -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