From 9506c14d35d344e488193769673f1311d828fd68 Mon Sep 17 00:00:00 2001 From: Marica Date: Wed, 1 Sep 2021 18:49:12 +0530 Subject: [PATCH] fix: Zero division error while fetching unconsumed materials (#27293) ` --- erpnext/stock/doctype/stock_entry/stock_entry.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 760cb7db66..c5c2868c63 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -1200,10 +1200,10 @@ class StockEntry(StockController): wo_item_qty = item.transferred_qty or item.required_qty - req_qty_each = ( - (flt(wo_item_qty) - flt(item.consumed_qty)) / - (flt(work_order_qty) - flt(wo.produced_qty)) - ) + wo_qty_consumed = flt(wo_item_qty) - flt(item.consumed_qty) + wo_qty_to_produce = flt(work_order_qty) - flt(wo.produced_qty) + + req_qty_each = (wo_qty_consumed) / (wo_qty_to_produce or 1) qty = req_qty_each * flt(self.fg_completed_qty) @@ -1582,7 +1582,7 @@ class StockEntry(StockController): if material_request and material_request not in material_requests: material_requests.append(material_request) frappe.db.set_value('Material Request', material_request, 'transfer_status', status) - + def update_items_for_process_loss(self): process_loss_dict = {} for d in self.get("items"):