implement note duplication serializers
This commit is contained in:
parent
fa447473d3
commit
18ea4b51e5
|
|
@ -191,7 +191,9 @@ class BuildSerializer(
|
|||
|
||||
return queryset
|
||||
|
||||
duplicate = DuplicateOptionsSerializer(Build.objects.all(), copy_parameters=True)
|
||||
duplicate = DuplicateOptionsSerializer(
|
||||
Build.objects.all(), copy_parameters=True, copy_notes=True
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Determine if extra serializer fields are required."""
|
||||
|
|
@ -212,6 +214,9 @@ class BuildSerializer(
|
|||
if duplicate.get('copy_parameters', True):
|
||||
instance.copy_parameters_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', True):
|
||||
instance.copy_notes_from(original)
|
||||
|
||||
return instance
|
||||
|
||||
def validate_reference(self, reference):
|
||||
|
|
|
|||
|
|
@ -193,7 +193,9 @@ class CompanySerializer(
|
|||
|
||||
parameters = common.filters.enable_parameters_filter()
|
||||
|
||||
duplicate = DuplicateOptionsSerializer(Company.objects.all(), copy_parameters=True)
|
||||
duplicate = DuplicateOptionsSerializer(
|
||||
Company.objects.all(), copy_parameters=True, copy_notes=True
|
||||
)
|
||||
|
||||
@transaction.atomic
|
||||
def create(self, validated_data):
|
||||
|
|
@ -208,6 +210,9 @@ class CompanySerializer(
|
|||
if duplicate.get('copy_parameters', True):
|
||||
instance.copy_parameters_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', True):
|
||||
instance.copy_notes_from(original)
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
|
|
@ -262,7 +267,7 @@ class ManufacturerPartSerializer(
|
|||
parameters = common.filters.enable_parameters_filter()
|
||||
|
||||
duplicate = DuplicateOptionsSerializer(
|
||||
ManufacturerPart.objects.all(), copy_parameters=True
|
||||
ManufacturerPart.objects.all(), copy_parameters=True, copy_notes=True
|
||||
)
|
||||
|
||||
@transaction.atomic
|
||||
|
|
@ -278,6 +283,9 @@ class ManufacturerPartSerializer(
|
|||
if duplicate.get('copy_parameters', True):
|
||||
instance.copy_parameters_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', True):
|
||||
instance.copy_notes_from(original)
|
||||
|
||||
return instance
|
||||
|
||||
part_detail = OptionalField(
|
||||
|
|
@ -535,7 +543,7 @@ class SupplierPartSerializer(
|
|||
updated = serializers.DateTimeField(allow_null=True, read_only=True)
|
||||
|
||||
duplicate = DuplicateOptionsSerializer(
|
||||
SupplierPart.objects.all(), copy_parameters=True
|
||||
SupplierPart.objects.all(), copy_parameters=True, copy_notes=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -594,6 +602,9 @@ class SupplierPartSerializer(
|
|||
if duplicate.get('copy_parameters', True):
|
||||
supplier_part.copy_parameters_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', True):
|
||||
supplier_part.copy_notes_from(original)
|
||||
|
||||
return supplier_part
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -269,6 +269,9 @@ class AbstractOrderSerializer(
|
|||
if duplicate.get('copy_parameters', False):
|
||||
instance.copy_parameters_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', False):
|
||||
instance.copy_notes_from(original)
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
|
|
@ -407,6 +410,7 @@ class PurchaseOrderSerializer(
|
|||
copy_lines=True,
|
||||
copy_extra_lines=True,
|
||||
copy_parameters=True,
|
||||
copy_notes=True,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -1095,6 +1099,7 @@ class SalesOrderSerializer(
|
|||
copy_lines=True,
|
||||
copy_extra_lines=True,
|
||||
copy_parameters=True,
|
||||
copy_notes=True,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -1472,7 +1477,9 @@ class SalesOrderShipmentSerializer(
|
|||
tags = common.filters.enable_tags_filter()
|
||||
|
||||
duplicate = DuplicateOptionsSerializer(
|
||||
order.models.SalesOrderShipment.objects.all(), copy_parameters=True
|
||||
order.models.SalesOrderShipment.objects.all(),
|
||||
copy_parameters=True,
|
||||
copy_notes=True,
|
||||
)
|
||||
|
||||
@transaction.atomic
|
||||
|
|
@ -1488,6 +1495,9 @@ class SalesOrderShipmentSerializer(
|
|||
if duplicate.get('copy_parameters', True):
|
||||
instance.copy_parameters_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', True):
|
||||
instance.copy_notes_from(original)
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
|
|
@ -2186,6 +2196,7 @@ class ReturnOrderSerializer(
|
|||
order.models.ReturnOrder.objects.all(),
|
||||
copy_extra_lines=True,
|
||||
copy_parameters=True,
|
||||
copy_notes=True,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -2476,7 +2487,10 @@ class TransferOrderSerializer(
|
|||
|
||||
# Note: TransferOrder does not have "extra" line items
|
||||
duplicate = DuplicateOptionsSerializer(
|
||||
order.models.TransferOrder.objects.all(), copy_lines=True, copy_parameters=True
|
||||
order.models.TransferOrder.objects.all(),
|
||||
copy_lines=True,
|
||||
copy_parameters=True,
|
||||
copy_notes=True,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -1046,8 +1046,7 @@ class PartSerializer(
|
|||
instance.copy_bom_from(original)
|
||||
|
||||
if duplicate.get('copy_notes', False):
|
||||
instance.notes = original.notes
|
||||
instance.save()
|
||||
instance.copy_notes_from(original)
|
||||
|
||||
if duplicate.get('copy_image', False):
|
||||
instance.image = original.image
|
||||
|
|
|
|||
Loading…
Reference in New Issue