From 1d1bc27a572f84471e0be12a63980a9dc1b46337 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 14 Jun 2016 16:27:50 +0530 Subject: [PATCH] [minor] fix update_mins_to_first_response patch --- erpnext/patches/v7_0/update_mins_to_first_response.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/patches/v7_0/update_mins_to_first_response.py b/erpnext/patches/v7_0/update_mins_to_first_response.py index 566627e510..a89a9c8129 100644 --- a/erpnext/patches/v7_0/update_mins_to_first_response.py +++ b/erpnext/patches/v7_0/update_mins_to_first_response.py @@ -7,12 +7,14 @@ def execute(): frappe.reload_doctype('Opportunity') for doctype in ('Issue', 'Opportunity'): - for parent in frappe.get_all(doctype, order_by='creation desc', limit=1000): + frappe.db.sql('update tab{0} set mins_to_first_response=0'.format(doctype)) + for parent in frappe.get_all(doctype, order_by='creation desc', limit=500): + parent_doc = frappe.get_doc(doctype, parent.name) for communication in frappe.get_all('Communication', - filters={'reference_doctype': doctype, 'reference_name': parent.name}, - order_by = 'creation desc', limit=2): + filters={'reference_doctype': doctype, 'reference_name': parent.name, + 'communication_medium': 'Email'}, + order_by = 'creation asc', limit=2): - parent_doc = frappe.get_doc(doctype, parent.name) communication_doc = frappe.get_doc('Communication', communication.name) update_mins_to_first_communication(parent_doc, communication_doc)