Fix Purchase Order Issue in Update Items (#15811)
* Fix Purchase Order Issue in Update Items
* fix(zero-division)
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 33f70cb..36200c7 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -295,7 +295,10 @@
for item in self.items:
received_qty += item.received_qty
total_qty += item.qty
- self.db_set("per_received", flt(received_qty/total_qty) * 100, update_modified=False)
+ if total_qty:
+ self.db_set("per_received", flt(received_qty/total_qty) * 100, update_modified=False)
+ else:
+ self.db_set("per_received", 0, update_modified=False)
def item_last_purchase_rate(name, conversion_rate, item_code, conversion_factor= 1.0):
"""get last purchase rate for an item"""