From 049ed87f8f1ad6cc1c83348aac698c7b8ec7dd68 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sat, 29 Nov 2025 11:50:45 +0330 Subject: [PATCH] fix - update transaction bug in items --- apps/warehouse/models.py | 2 +- apps/warehouse/pos/api/v2/serializers.py | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/apps/warehouse/models.py b/apps/warehouse/models.py index 60e0203..1eea1db 100644 --- a/apps/warehouse/models.py +++ b/apps/warehouse/models.py @@ -166,7 +166,7 @@ class InventoryQuotaSaleTransaction(BaseModel): return sum(item.weight for item in self.items.all) # noqa def __str__(self): - return f"Inventory Sale: {self.transaction_id}-{self.quota_distribution.distribution_id}" + return f"Inventory Sale: {self.transaction_id}" def save(self, *args, **kwargs): super(InventoryQuotaSaleTransaction, self).save(*args, **kwargs) diff --git a/apps/warehouse/pos/api/v2/serializers.py b/apps/warehouse/pos/api/v2/serializers.py index 77dd6dc..b006cd3 100644 --- a/apps/warehouse/pos/api/v2/serializers.py +++ b/apps/warehouse/pos/api/v2/serializers.py @@ -137,10 +137,9 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer): if transaction.transaction_status == 'success': for item_data in items_data: qs = warehouse_models.InventoryQuotaSaleItem.objects.filter( - Q(transaction=transaction) & ( - Q(free_product_id=item_data.get('free_product', None)) | - Q(gov_product_id=item_data.get('gov_product', None)) - ) + Q(free_product_id=item_data.get('free_product', None)), + Q(gov_product_id=item_data.get('gov_product', None)), + transaction=transaction, ).update(**item_data) return transaction @@ -172,10 +171,9 @@ class InventoryQuotaSaleTransactionSerializer(serializers.ModelSerializer): # items can change for item_data in items_data: items = warehouse_models.InventoryQuotaSaleItem.objects.filter( - Q(transaction=transaction) & ( - Q(free_product_id=item_data.get('free_product', None)) | - Q(gov_product_id=item_data.get('gov_product', None)) - ) + Q(free_product_id=item_data.get('free_product', None)), + Q(gov_product_id=item_data.get('gov_product', None)), + transaction=transaction, ) items.update(**item_data)