From 91d9025751baeb36a965a899581f8339a6e2b8a7 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sun, 10 Aug 2025 09:16:48 +0330 Subject: [PATCH] fix bug of inventory entry --- apps/warehouse/web/api/v1/serializers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/warehouse/web/api/v1/serializers.py b/apps/warehouse/web/api/v1/serializers.py index 9d3ec52..655ddb0 100644 --- a/apps/warehouse/web/api/v1/serializers.py +++ b/apps/warehouse/web/api/v1/serializers.py @@ -44,16 +44,17 @@ class InventoryEntrySerializer(serializers.ModelSerializer): # if instance exists, for update check weight with distribution weight if self.instance: - if self.instance.weight is 0: + if self.instance.weight == 0: if total_entered + attrs['weight'] > distribution.weight: raise InventoryEntryWeightException() - elif self.instance.weight is not 0: + elif self.instance.weight != 0: if total_entered - self.instance.weight + attrs['weight'] > distribution.weight: raise InventoryEntryWeightException() # if instance is not exists for create, check entry weight with distribution 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() return attrs