mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-05 06:48:48 +00:00
* Adds BuildLineLabel model - New type of label for printing against BuildLine objects * Add serializer for new model * Add API endpoints for new label type * Add hooks to BuildLine table * Create default label - Create an example BuildLineLabel object * Add admin integration * Fix js code * Use two-tiered template - Allows base template to be updated * Improve default label * Add docs pages for labels * Update nav * Documentation for new label * Add permission role * Bump API version
65 lines
1.6 KiB
Python
65 lines
1.6 KiB
Python
"""API serializers for the label app"""
|
|
|
|
import label.models
|
|
from InvenTree.serializers import (InvenTreeAttachmentSerializerField,
|
|
InvenTreeModelSerializer)
|
|
|
|
|
|
class LabelSerializerBase(InvenTreeModelSerializer):
|
|
"""Base class for label serializer"""
|
|
|
|
label = InvenTreeAttachmentSerializerField(required=True)
|
|
|
|
@staticmethod
|
|
def label_fields():
|
|
"""Generic serializer fields for a label template"""
|
|
|
|
return [
|
|
'pk',
|
|
'name',
|
|
'description',
|
|
'label',
|
|
'filters',
|
|
'enabled',
|
|
]
|
|
|
|
|
|
class StockItemLabelSerializer(LabelSerializerBase):
|
|
"""Serializes a StockItemLabel object."""
|
|
|
|
class Meta:
|
|
"""Metaclass options."""
|
|
|
|
model = label.models.StockItemLabel
|
|
fields = LabelSerializerBase.label_fields()
|
|
|
|
|
|
class StockLocationLabelSerializer(LabelSerializerBase):
|
|
"""Serializes a StockLocationLabel object."""
|
|
|
|
class Meta:
|
|
"""Metaclass options."""
|
|
|
|
model = label.models.StockLocationLabel
|
|
fields = LabelSerializerBase.label_fields()
|
|
|
|
|
|
class PartLabelSerializer(LabelSerializerBase):
|
|
"""Serializes a PartLabel object."""
|
|
|
|
class Meta:
|
|
"""Metaclass options."""
|
|
|
|
model = label.models.PartLabel
|
|
fields = LabelSerializerBase.label_fields()
|
|
|
|
|
|
class BuildLineLabelSerializer(LabelSerializerBase):
|
|
"""Serializes a BuildLineLabel object"""
|
|
|
|
class Meta:
|
|
"""Metaclass options."""
|
|
|
|
model = label.models.BuildLineLabel
|
|
fields = LabelSerializerBase.label_fields()
|