fix bug of inventory entry
This commit is contained in:
@@ -44,16 +44,17 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
# if instance exists, for update check weight with distribution weight
|
# if instance exists, for update check weight with distribution weight
|
||||||
if self.instance:
|
if self.instance:
|
||||||
if self.instance.weight is 0:
|
if self.instance.weight == 0:
|
||||||
if total_entered + attrs['weight'] > distribution.weight:
|
if total_entered + attrs['weight'] > distribution.weight:
|
||||||
raise InventoryEntryWeightException()
|
raise InventoryEntryWeightException()
|
||||||
elif self.instance.weight is not 0:
|
elif self.instance.weight != 0:
|
||||||
if total_entered - self.instance.weight + attrs['weight'] > distribution.weight:
|
if total_entered - self.instance.weight + attrs['weight'] > distribution.weight:
|
||||||
raise InventoryEntryWeightException()
|
raise InventoryEntryWeightException()
|
||||||
|
|
||||||
# if instance is not exists for create, check entry weight with distribution
|
# if instance is not exists for create, check entry weight with distribution
|
||||||
else:
|
else:
|
||||||
if total_entered + attrs['weight'] > distribution.weight:
|
if total_entered + attrs['weight'] > distribution.weight or \
|
||||||
|
total_entered + attrs['weight'] > distribution.remaining_weight:
|
||||||
raise InventoryEntryWeightException()
|
raise InventoryEntryWeightException()
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|||||||
Reference in New Issue
Block a user