Merge branch 'develop' into mapped_doc_fix
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index fa51638..36a31cf 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -607,3 +607,4 @@
 erpnext.patches.v12_0.make_item_manufacturer
 erpnext.patches.v12_0.set_quotation_status
 erpnext.patches.v12_0.set_priority_for_support
+erpnext.patches.v12_0.delete_priority_property_setter
diff --git a/erpnext/patches/v12_0/delete_priority_property_setter.py b/erpnext/patches/v12_0/delete_priority_property_setter.py
new file mode 100644
index 0000000..5927267
--- /dev/null
+++ b/erpnext/patches/v12_0/delete_priority_property_setter.py
@@ -0,0 +1,9 @@
+import frappe
+
+def execute():
+	frappe.db.sql("""
+		DELETE FROM `tabProperty Setter`
+		WHERE `tabProperty Setter`.doc_type='Issue'
+			AND `tabProperty Setter`.field_name='priority'
+			AND `tabProperty Setter`.property='options'
+	""")
\ No newline at end of file
diff --git a/erpnext/support/doctype/issue/issue.js b/erpnext/support/doctype/issue/issue.js
index ba54edc..1a272d1 100644
--- a/erpnext/support/doctype/issue/issue.js
+++ b/erpnext/support/doctype/issue/issue.js
@@ -73,27 +73,6 @@
 		}
 	},
 
-	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 70430b1..3b703d9 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -29,6 +29,7 @@
 		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 @@
 		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 332bf63..5536cc9 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 @@
 				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: