fix(set_purchase_receipt_delivery_note_detail): commit after every 100 sql updates (#22016)

This commit is contained in:
sahil28297 2020-05-28 18:49:47 +05:30 committed by GitHub
parent 1f3fe59e36
commit 9209b9a7de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,11 +64,13 @@ def execute():
return_document_map = make_return_document_map(doctype, return_document_map) return_document_map = make_return_document_map(doctype, return_document_map)
count = 0
#iterate through original documents and its return documents #iterate through original documents and its return documents
for docname in return_document_map: for docname in return_document_map:
doc_items = frappe.get_doc(doctype, docname).get("items") doc_items = frappe.get_cached_doc(doctype, docname).get("items")
for return_doc in return_document_map[docname]: for return_doc in return_document_map[docname]:
return_doc_items = frappe.get_doc(doctype, return_doc).get("items") return_doc_items = frappe.get_cached_doc(doctype, return_doc).get("items")
#iterate through return document items and original document items for mapping #iterate through return document items and original document items for mapping
for return_item in return_doc_items: for return_item in return_doc_items:
@ -80,9 +82,11 @@ def execute():
else: else:
continue continue
# commit after every 100 sql updates
count += 1
if count%100 == 0:
frappe.db.commit()
set_document_detail_in_return_document("Purchase Receipt") set_document_detail_in_return_document("Purchase Receipt")
set_document_detail_in_return_document("Delivery Note") set_document_detail_in_return_document("Delivery Note")
frappe.db.commit() frappe.db.commit()