Fix:
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:
@ -177,7 +177,7 @@ def update_inventory(voucher: Voucher, new_inventories: List[schema_in.Inventory
|
|||||||
found = False
|
found = False
|
||||||
for j in range(len(new_inventories), 0, -1):
|
for j in range(len(new_inventories), 0, -1):
|
||||||
new_inventory = new_inventories[j - 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()
|
product = db.query(Product).filter(Product.id == new_inventory.product.id_).first()
|
||||||
found = True
|
found = True
|
||||||
if item.product_id != new_inventory.product.id_:
|
if item.product_id != new_inventory.product.id_:
|
||||||
|
|||||||
@ -173,7 +173,7 @@ def update_inventory(voucher: Voucher, new_inventories: List[schema_in.Inventory
|
|||||||
found = False
|
found = False
|
||||||
for j in range(len(new_inventories), 0, -1):
|
for j in range(len(new_inventories), 0, -1):
|
||||||
new_inventory = new_inventories[j - 1]
|
new_inventory = new_inventories[j - 1]
|
||||||
if new_inventory.id_:
|
if new_inventory.id_ == item.id:
|
||||||
found = True
|
found = True
|
||||||
if item.product_id != new_inventory.product.id_:
|
if item.product_id != new_inventory.product.id_:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
Reference in New Issue
Block a user