From c5fcbeff7a391cccfb01a75c179ab3bae9e64239 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Tue, 14 Dec 2021 18:45:27 +0530 Subject: [PATCH] fix: reset_expected_response_and_resolution on hold --- .../service_level_agreement.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py index 50f31fde2d..83ec5e7c8e 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py @@ -420,13 +420,13 @@ def handle_status_change(doc, apply_sla_for_resolution): if is_open_status(prev_status) and is_hold_status(doc.status): # Issue is on hold -> Set on_hold_since doc.on_hold_since = now_time + reset_expected_response_and_resolution(doc) # Replied to Open if is_hold_status(prev_status) and is_open_status(doc.status): # Issue was on hold -> Calculate Total Hold Time calculate_hold_hours() # Issue is open -> reset resolution_date - reset_expected_response_and_resolution(doc) reset_resolution_metrics(doc) # Open to Closed @@ -440,7 +440,6 @@ def handle_status_change(doc, apply_sla_for_resolution): # Issue was closed -> Calculate Total Hold Time from resolution_date calculate_hold_hours() # Issue is open -> reset resolution_date - reset_expected_response_and_resolution(doc) reset_resolution_metrics(doc) # Closed to Replied @@ -449,6 +448,7 @@ def handle_status_change(doc, apply_sla_for_resolution): calculate_hold_hours() # Issue is on hold -> Set on_hold_since doc.on_hold_since = now_time + reset_expected_response_and_resolution(doc) # Replied to Closed if is_hold_status(prev_status) and is_fulfilled_status(doc.status): @@ -645,7 +645,7 @@ def on_communication_update(doc, status): if ( doc.sent_or_received == "Received" # a reply is received and parent.get('status') == 'Open' # issue status is set as open from communication.py - and parent._doc_before_save + and parent.get_doc_before_save() and parent.get('status') != parent._doc_before_save.get('status') # status changed ): # undo the status change in db @@ -655,13 +655,16 @@ def on_communication_update(doc, status): elif ( doc.sent_or_received == "Sent" # a reply is sent and parent.get('first_responded_on') # first_responded_on is set from communication.py - and parent._doc_before_save + and parent.get_doc_before_save() and not parent._doc_before_save.get('first_responded_on') # first_responded_on was not set ): # reset first_responded_on since it will be handled/set later on parent.first_responded_on = None parent.flags.on_first_reply = True + else: + return + handle_status_change(parent, for_resolution) update_response_and_resolution_metrics(parent, for_resolution) update_agreement_status(parent, for_resolution)