mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add serializer for the ReturnOrderReport model
- A little bit of refactoring along the way
This commit is contained in:
parent
6675f88476
commit
096b6aeaa7
@ -4,99 +4,83 @@ from InvenTree.serializers import (InvenTreeAttachmentSerializerField,
|
|||||||
InvenTreeModelSerializer)
|
InvenTreeModelSerializer)
|
||||||
|
|
||||||
from .models import (BillOfMaterialsReport, BuildReport, PurchaseOrderReport,
|
from .models import (BillOfMaterialsReport, BuildReport, PurchaseOrderReport,
|
||||||
SalesOrderReport, TestReport)
|
ReturnOrderReport, SalesOrderReport, TestReport)
|
||||||
|
|
||||||
|
|
||||||
class TestReportSerializer(InvenTreeModelSerializer):
|
class ReportSerializerBase(InvenTreeModelSerializer):
|
||||||
|
"""Base class for report serializer"""
|
||||||
|
|
||||||
|
template = InvenTreeAttachmentSerializerField(required=True)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def report_fields():
|
||||||
|
"""Generic serializer fields for a report template"""
|
||||||
|
|
||||||
|
return [
|
||||||
|
'pk',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'template',
|
||||||
|
'filters',
|
||||||
|
'enabled',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TestReportSerializer(ReportSerializerBase):
|
||||||
"""Serializer class for the TestReport model"""
|
"""Serializer class for the TestReport model"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Metaclass options."""
|
"""Metaclass options."""
|
||||||
|
|
||||||
model = TestReport
|
model = TestReport
|
||||||
fields = [
|
fields = ReportSerializerBase.report_fields()
|
||||||
'pk',
|
|
||||||
'name',
|
|
||||||
'description',
|
|
||||||
'template',
|
|
||||||
'filters',
|
|
||||||
'enabled',
|
|
||||||
]
|
|
||||||
|
|
||||||
template = InvenTreeAttachmentSerializerField(required=True)
|
|
||||||
|
|
||||||
|
|
||||||
class BuildReportSerializer(InvenTreeModelSerializer):
|
class BuildReportSerializer(ReportSerializerBase):
|
||||||
"""Serializer class for the BuildReport model"""
|
"""Serializer class for the BuildReport model"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Metaclass options."""
|
"""Metaclass options."""
|
||||||
|
|
||||||
model = BuildReport
|
model = BuildReport
|
||||||
fields = [
|
fields = ReportSerializerBase.report_fields()
|
||||||
'pk',
|
|
||||||
'name',
|
|
||||||
'description',
|
|
||||||
'template',
|
|
||||||
'filters',
|
|
||||||
'enabled',
|
|
||||||
]
|
|
||||||
|
|
||||||
template = InvenTreeAttachmentSerializerField(required=True)
|
|
||||||
|
|
||||||
|
|
||||||
class BOMReportSerializer(InvenTreeModelSerializer):
|
class BOMReportSerializer(ReportSerializerBase):
|
||||||
"""Serializer class for the BillOfMaterialsReport model"""
|
"""Serializer class for the BillOfMaterialsReport model"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Metaclass options."""
|
"""Metaclass options."""
|
||||||
|
|
||||||
model = BillOfMaterialsReport
|
model = BillOfMaterialsReport
|
||||||
fields = [
|
fields = ReportSerializerBase.report_fields()
|
||||||
'pk',
|
|
||||||
'name',
|
|
||||||
'description',
|
|
||||||
'template',
|
|
||||||
'filters',
|
|
||||||
'enabled',
|
|
||||||
]
|
|
||||||
|
|
||||||
template = InvenTreeAttachmentSerializerField(required=True)
|
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrderReportSerializer(InvenTreeModelSerializer):
|
class PurchaseOrderReportSerializer(ReportSerializerBase):
|
||||||
"""Serializer class for the PurchaseOrdeReport model"""
|
"""Serializer class for the PurchaseOrdeReport model"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Metaclass options."""
|
"""Metaclass options."""
|
||||||
|
|
||||||
model = PurchaseOrderReport
|
model = PurchaseOrderReport
|
||||||
fields = [
|
fields = ReportSerializerBase.report_fields()
|
||||||
'pk',
|
|
||||||
'name',
|
|
||||||
'description',
|
|
||||||
'template',
|
|
||||||
'filters',
|
|
||||||
'enabled',
|
|
||||||
]
|
|
||||||
|
|
||||||
template = InvenTreeAttachmentSerializerField(required=True)
|
|
||||||
|
|
||||||
|
|
||||||
class SalesOrderReportSerializer(InvenTreeModelSerializer):
|
class SalesOrderReportSerializer(ReportSerializerBase):
|
||||||
"""Serializer class for the SalesOrderReport model"""
|
"""Serializer class for the SalesOrderReport model"""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Metaclass options."""
|
"""Metaclass options."""
|
||||||
|
|
||||||
model = SalesOrderReport
|
model = SalesOrderReport
|
||||||
fields = [
|
fields = ReportSerializerBase.report_fields()
|
||||||
'pk',
|
|
||||||
'name',
|
|
||||||
'description',
|
|
||||||
'template',
|
|
||||||
'filters',
|
|
||||||
'enabled',
|
|
||||||
]
|
|
||||||
|
|
||||||
template = InvenTreeAttachmentSerializerField(required=True)
|
|
||||||
|
class ReturnOrderReportSerializer(ReportSerializerBase):
|
||||||
|
"""Serializer class for the ReturnOrderReport model"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
"""Metaclass options"""
|
||||||
|
|
||||||
|
model = ReturnOrderReport
|
||||||
|
fields = ReportSerializerBase.report_fields()
|
||||||
|
Loading…
Reference in New Issue
Block a user