From ca6e2236944f9a6ff475d17135f0ce3e5e8a35dc Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 5 Mar 2018 17:03:05 +0530 Subject: [PATCH] [fix] use join instead of subquery --- .../update_status_for_multiple_source_in_po.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py b/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py index 1de9d976f8..fd3be08b89 100644 --- a/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py +++ b/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py @@ -9,15 +9,17 @@ def execute(): # update the sales order item in the material request frappe.reload_doc('stock', 'doctype', 'material_request_item') - frappe.db.sql('''update `tabMaterial Request Item` mri set sales_order_item = (select name from - `tabSales Order Item` soi where soi.parent=mri.sales_order and soi.item_code=mri.item_code) where docstatus = 1 and - ifnull(mri.sales_order, "")!="" + frappe.db.sql('''update `tabMaterial Request Item` mri, `tabSales Order Item` soi + set mri.sales_order_item = soi.name + where ifnull(mri.sales_order, "")!="" and soi.parent=mri.sales_order + and soi.item_code=mri.item_code and mri.docstatus=1 ''') # update the sales order item in the purchase order - frappe.db.sql('''update `tabPurchase Order Item` poi set sales_order_item = (select name from - `tabSales Order Item` soi where soi.parent=poi.sales_order and soi.item_code=poi.item_code) where docstatus = 1 and - ifnull(poi.sales_order, "")!="" + frappe.db.sql('''update `tabPurchase Order Item` poi, `tabSales Order Item` soi + set poi.sales_order_item = soi.name + where ifnull(poi.sales_order, "")!="" and soi.parent=poi.sales_order + and soi.item_code=poi.item_code and poi.docstatus = 1 ''') # Update the status in material request and sales order