Merge pull request #28887 from nextchamp-saqib/sla-fixes-#1
fix: reset_expected_response_and_resolution on hold
This commit is contained in:
commit
5cf5412827
@ -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):
|
if is_open_status(prev_status) and is_hold_status(doc.status):
|
||||||
# Issue is on hold -> Set on_hold_since
|
# Issue is on hold -> Set on_hold_since
|
||||||
doc.on_hold_since = now_time
|
doc.on_hold_since = now_time
|
||||||
|
reset_expected_response_and_resolution(doc)
|
||||||
|
|
||||||
# Replied to Open
|
# Replied to Open
|
||||||
if is_hold_status(prev_status) and is_open_status(doc.status):
|
if is_hold_status(prev_status) and is_open_status(doc.status):
|
||||||
# Issue was on hold -> Calculate Total Hold Time
|
# Issue was on hold -> Calculate Total Hold Time
|
||||||
calculate_hold_hours()
|
calculate_hold_hours()
|
||||||
# Issue is open -> reset resolution_date
|
# Issue is open -> reset resolution_date
|
||||||
reset_expected_response_and_resolution(doc)
|
|
||||||
reset_resolution_metrics(doc)
|
reset_resolution_metrics(doc)
|
||||||
|
|
||||||
# Open to Closed
|
# 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
|
# Issue was closed -> Calculate Total Hold Time from resolution_date
|
||||||
calculate_hold_hours()
|
calculate_hold_hours()
|
||||||
# Issue is open -> reset resolution_date
|
# Issue is open -> reset resolution_date
|
||||||
reset_expected_response_and_resolution(doc)
|
|
||||||
reset_resolution_metrics(doc)
|
reset_resolution_metrics(doc)
|
||||||
|
|
||||||
# Closed to Replied
|
# Closed to Replied
|
||||||
@ -449,6 +448,7 @@ def handle_status_change(doc, apply_sla_for_resolution):
|
|||||||
calculate_hold_hours()
|
calculate_hold_hours()
|
||||||
# Issue is on hold -> Set on_hold_since
|
# Issue is on hold -> Set on_hold_since
|
||||||
doc.on_hold_since = now_time
|
doc.on_hold_since = now_time
|
||||||
|
reset_expected_response_and_resolution(doc)
|
||||||
|
|
||||||
# Replied to Closed
|
# Replied to Closed
|
||||||
if is_hold_status(prev_status) and is_fulfilled_status(doc.status):
|
if is_hold_status(prev_status) and is_fulfilled_status(doc.status):
|
||||||
@ -640,28 +640,35 @@ def on_communication_update(doc, status):
|
|||||||
if not parent.meta.has_field('service_level_agreement'):
|
if not parent.meta.has_field('service_level_agreement'):
|
||||||
return
|
return
|
||||||
|
|
||||||
for_resolution = frappe.db.get_value('Service Level Agreement', parent.service_level_agreement, 'apply_sla_for_resolution')
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
doc.sent_or_received == "Received" # a reply is received
|
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.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
|
and parent.get('status') != parent._doc_before_save.get('status') # status changed
|
||||||
):
|
):
|
||||||
# undo the status change in db
|
# undo the status change in db
|
||||||
# since prev status is fetched from db
|
# since prev status is fetched from db
|
||||||
frappe.db.set_value(parent.doctype, parent.name, 'status', parent._doc_before_save.get('status'))
|
frappe.db.set_value(
|
||||||
|
parent.doctype, parent.name,
|
||||||
|
'status', parent._doc_before_save.get('status'),
|
||||||
|
update_modified=False
|
||||||
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
doc.sent_or_received == "Sent" # a reply is sent
|
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.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
|
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
|
# reset first_responded_on since it will be handled/set later on
|
||||||
parent.first_responded_on = None
|
parent.first_responded_on = None
|
||||||
parent.flags.on_first_reply = True
|
parent.flags.on_first_reply = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
for_resolution = frappe.db.get_value('Service Level Agreement', parent.service_level_agreement, 'apply_sla_for_resolution')
|
||||||
|
|
||||||
handle_status_change(parent, for_resolution)
|
handle_status_change(parent, for_resolution)
|
||||||
update_response_and_resolution_metrics(parent, for_resolution)
|
update_response_and_resolution_metrics(parent, for_resolution)
|
||||||
update_agreement_status(parent, for_resolution)
|
update_agreement_status(parent, for_resolution)
|
||||||
@ -670,12 +677,10 @@ def on_communication_update(doc, status):
|
|||||||
|
|
||||||
|
|
||||||
def reset_expected_response_and_resolution(doc):
|
def reset_expected_response_and_resolution(doc):
|
||||||
update_values = {}
|
|
||||||
if doc.meta.has_field("first_responded_on") and not doc.get('first_responded_on'):
|
if doc.meta.has_field("first_responded_on") and not doc.get('first_responded_on'):
|
||||||
update_values['response_by'] = None
|
doc.response_by = None
|
||||||
if doc.meta.has_field("resolution_by") and not doc.get('resolution_date'):
|
if doc.meta.has_field("resolution_by") and not doc.get('resolution_date'):
|
||||||
update_values['resolution_by'] = None
|
doc.resolution_by = None
|
||||||
doc.db_set(update_values)
|
|
||||||
|
|
||||||
|
|
||||||
def set_response_by(doc, start_date_time, priority):
|
def set_response_by(doc, start_date_time, priority):
|
||||||
|
Loading…
Reference in New Issue
Block a user