From d9b9f4e8b76d529ade481483b161df0a50ce3530 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 29 Dec 2021 10:14:03 +0530 Subject: [PATCH] fix: optimize patch for update bom in SO and MR --- erpnext/patches/v12_0/update_bom_in_so_mr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v12_0/update_bom_in_so_mr.py b/erpnext/patches/v12_0/update_bom_in_so_mr.py index 37d850fab4..132f3bd3b1 100644 --- a/erpnext/patches/v12_0/update_bom_in_so_mr.py +++ b/erpnext/patches/v12_0/update_bom_in_so_mr.py @@ -6,7 +6,7 @@ def execute(): frappe.reload_doc("selling", "doctype", "sales_order_item") for doctype in ["Sales Order", "Material Request"]: - condition = " and child_doc.stock_qty > child_doc.produced_qty" + condition = " and child_doc.stock_qty > child_doc.produced_qty and doc.per_delivered < 100" if doctype == "Material Request": condition = " and doc.per_ordered < 100 and doc.material_request_type = 'Manufacture'" @@ -15,5 +15,6 @@ def execute(): child_doc.bom_no = item.default_bom WHERE child_doc.item_code = item.name and child_doc.docstatus < 2 + and child_doc.parent = doc.name and item.default_bom is not null and item.default_bom != '' {cond} """.format(doc = doctype, cond = condition))