fix inventory edit weight bug - fix inventory document - set new validations for distribution
This commit is contained in:
@@ -70,7 +70,6 @@ class InventoryEntryViewSet(viewsets.ModelViewSet, DynamicSearchMixin):
|
||||
@transaction.atomic
|
||||
def update(self, request, pk=None, *args, **kwargs):
|
||||
""" edit inventory """
|
||||
|
||||
inventory = self.get_object()
|
||||
serializer = self.serializer_class(data=request.data, instance=inventory, partial=True)
|
||||
if serializer.is_valid():
|
||||
|
||||
@@ -42,8 +42,12 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
||||
total=models.Sum('weight')
|
||||
)['total'] or 0
|
||||
|
||||
if total_entered + attrs['weight'] > distribution.weight:
|
||||
raise InventoryEntryWeightException()
|
||||
if self.instance.weight is 0:
|
||||
if total_entered + attrs['weight'] > distribution.weight:
|
||||
raise InventoryEntryWeightException()
|
||||
elif self.instance.weight is not 0:
|
||||
if total_entered - self.instance.weight + attrs['weight'] > distribution.weight:
|
||||
raise InventoryEntryWeightException()
|
||||
|
||||
return attrs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user