diff --git a/erpnext/patches/v12_0/set_priority_for_support.py b/erpnext/patches/v12_0/set_priority_for_support.py index cc290396f8..4eae0654e8 100644 --- a/erpnext/patches/v12_0/set_priority_for_support.py +++ b/erpnext/patches/v12_0/set_priority_for_support.py @@ -18,6 +18,8 @@ def set_issue_priority(): "name": priority }).insert(ignore_permissions=True) + frappe.delete_doc_if_exists("Property Setter", {"field_name": "priority", "property": "options"}) + def set_priority_for_issue(): # Sets priority for Issues as Select field is changed to Link field. issue_priority = frappe.get_list("Issue", fields=["name", "priority"]) diff --git a/erpnext/support/doctype/issue/issue.js b/erpnext/support/doctype/issue/issue.js index ba54edcf39..1a272d1bc4 100644 --- a/erpnext/support/doctype/issue/issue.js +++ b/erpnext/support/doctype/issue/issue.js @@ -73,27 +73,6 @@ frappe.ui.form.on("Issue", { } }, - priority: function(frm) { - if (frm.doc.service_level_agreement) { - frm.call('change_service_level_agreement_and_priority', { - "priority": frm.doc.priority, - "service_level_agreement": frm.doc.service_level_agreement - }).then(() => { - frappe.msgprint(__("Issue Priority changed to {0}.", [frm.doc.priority])); - frm.refresh(); - }); - } - }, - - service_level_agreement: function(frm) { - frm.call('change_service_level_agreement_and_priority', { - "service_level_agreement": frm.doc.service_level_agreement - }).then(() => { - frappe.msgprint(__("Service Level Agreement changed to {0}.", [frm.doc.service_level_agreement])); - frm.refresh(); - }); - }, - timeline_refresh: function(frm) { // create button for "Help Article" if(frappe.model.can_create('Help Article')) { diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py index 70430b16bb..3b703d9a21 100644 --- a/erpnext/support/doctype/issue/issue.py +++ b/erpnext/support/doctype/issue/issue.py @@ -29,6 +29,7 @@ class Issue(Document): if not self.raised_by: self.raised_by = frappe.session.user + self.change_service_level_agreement_and_priority() self.update_status() self.set_lead_contact(self.raised_by) @@ -173,9 +174,14 @@ class Issue(Document): self.response_by_variance = round(time_diff_in_hours(self.response_by, now_datetime())) self.resolution_by_variance = round(time_diff_in_hours(self.resolution_by, now_datetime())) - def change_service_level_agreement_and_priority(self, priority=None, service_level_agreement=None): - self.set_response_and_resolution_time(priority=priority, service_level_agreement=service_level_agreement) - self.save(ignore_permissions=True) + def change_service_level_agreement_and_priority(self): + if not self.priority == frappe.db.get_value("Issue", self.name, "priority"): + self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement) + frappe.msgprint("Priority has been updated.") + + if not self.service_level_agreement == frappe.db.get_value("Issue", self.name, "service_level_agreement"): + self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement) + frappe.msgprint("Service Level Agreement has been updated.") def get_expected_time_for(parameter, service_level, start_date_time): current_date_time = start_date_time 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 332bf63580..5536cc9df3 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py @@ -18,7 +18,7 @@ class ServiceLevelAgreement(Document): if self.start_date >= self.end_date: frappe.throw(_("Start Date of Agreement can't be greater than or equal to End Date.")) - if self.end_date < frappe.utils.getdate(): + if self.end_date < frappe.utils.nowdate(): frappe.throw(_("End Date of Agreement can't be less than today.")) if self.entity_type and self.entity: