Update in purchase/return would give wrong product changed error when a product was deleted as the id of the inventory was not checked properly
This commit is contained in:
Amritanshu Agrawal 2020-10-01 12:38:54 +05:30
parent 4685fa2528
commit 40e79ff949
2 changed files with 2 additions and 2 deletions

View File

@ -177,7 +177,7 @@ def update_inventory(voucher: Voucher, new_inventories: List[schema_in.Inventory
found = False
for j in range(len(new_inventories), 0, -1):
new_inventory = new_inventories[j - 1]
if new_inventory.id_:
if new_inventory.id_ == item.id:
product = db.query(Product).filter(Product.id == new_inventory.product.id_).first()
found = True
if item.product_id != new_inventory.product.id_:

View File

@ -173,7 +173,7 @@ def update_inventory(voucher: Voucher, new_inventories: List[schema_in.Inventory
found = False
for j in range(len(new_inventories), 0, -1):
new_inventory = new_inventories[j - 1]
if new_inventory.id_:
if new_inventory.id_ == item.id:
found = True
if item.product_id != new_inventory.product.id_:
raise HTTPException(