fix(Issue): reset response_by and resolution_by if SLA is removed (#25997)
diff --git a/erpnext/support/doctype/issue/issue.json b/erpnext/support/doctype/issue/issue.json
index bc29821..14712f8 100644
--- a/erpnext/support/doctype/issue/issue.json
+++ b/erpnext/support/doctype/issue/issue.json
@@ -166,7 +166,7 @@
"options": "Service Level Agreement"
},
{
- "depends_on": "eval: doc.status != 'Replied';",
+ "depends_on": "eval: doc.status != 'Replied' && doc.service_level_agreement;",
"fieldname": "response_by",
"fieldtype": "Datetime",
"label": "Response By",
@@ -180,7 +180,7 @@
"read_only": 1
},
{
- "depends_on": "eval: doc.status != 'Replied';",
+ "depends_on": "eval: doc.status != 'Replied' && doc.service_level_agreement;",
"fieldname": "resolution_by",
"fieldtype": "Datetime",
"label": "Resolution By",
@@ -410,7 +410,7 @@
"icon": "fa fa-ticket",
"idx": 7,
"links": [],
- "modified": "2021-05-26 10:49:07.574769",
+ "modified": "2021-06-10 03:22:27.098898",
"modified_by": "Administrator",
"module": "Support",
"name": "Issue",
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index b068363..9c69deb 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -29,6 +29,9 @@
self.update_status()
self.set_lead_contact(self.raised_by)
+ if not self.service_level_agreement:
+ self.reset_sla_fields()
+
def on_update(self):
# Add a communication in the issue timeline
if self.flags.create_communication and self.via_customer_portal:
@@ -54,6 +57,13 @@
self.company = frappe.db.get_value("Lead", self.lead, "company") or \
frappe.db.get_default("Company")
+ def reset_sla_fields(self):
+ self.agreement_status = ""
+ self.response_by = ""
+ self.resolution_by = ""
+ self.response_by_variance = 0
+ self.resolution_by_variance = 0
+
def update_status(self):
status = frappe.db.get_value("Issue", self.name, "status")
if self.status != "Open" and status == "Open" and not self.first_responded_on:
@@ -511,4 +521,4 @@
Converts datetime.time(10, 36, 55, 961454) to datetime.timedelta(seconds=38215)
"""
import datetime
- return datetime.timedelta(hours=time.hour, minutes=time.minute, seconds=time.second)
\ No newline at end of file
+ return datetime.timedelta(hours=time.hour, minutes=time.minute, seconds=time.second)