Merge branch 'master' into develop
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 42f538d..0c7daad 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -4,7 +4,7 @@
 import frappe
 from erpnext.hooks import regional_overrides
 
-__version__ = '9.1.6'
+__version__ = '9.1.7'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 04f7e1b..6856f62 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -88,7 +88,7 @@
 	doc.naming_series = pos_profile.get('naming_series') or 'SINV-'
 	doc.letter_head = pos_profile.get('letter_head') or company_data.default_letter_head
 	doc.ignore_pricing_rule = pos_profile.get('ignore_pricing_rule') or 0
-	doc.apply_discount_on = pos_profile.get('apply_discount_on') or ''
+	doc.apply_discount_on = pos_profile.get('apply_discount_on') or 'Grand Total'
 	doc.customer_group = pos_profile.get('customer_group') or get_root('Customer Group')
 	doc.territory = pos_profile.get('territory') or get_root('Territory')
 	doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms') or doc.terms or ''
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 57a8a18..c442062 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -84,6 +84,7 @@
 		this.get_data_from_server(function () {
 			me.make_control();
 			me.create_new();
+			me.make();
 		});
 	},
 
@@ -382,7 +383,6 @@
 	},
 
 	setup: function () {
-		this.make();
 		this.set_primary_action();
 		this.party_field.$input.attr('disabled', false);
 		if(this.selected_row) {
@@ -1341,6 +1341,12 @@
 
 		this.wrapper.find('input.discount-percentage').on("change", function () {
 			me.frm.doc.additional_discount_percentage = flt($(this).val(), precision("additional_discount_percentage"));
+
+			if(me.frm.doc.additional_discount_percentage && me.frm.doc.discount_amount) {
+				// Reset discount amount
+				me.frm.doc.discount_amount = 0;
+			}
+
 			var total = me.frm.doc.grand_total
 
 			if (me.frm.doc.apply_discount_on == 'Net Total') {
@@ -1348,15 +1354,15 @@
 			}
 
 			me.frm.doc.discount_amount = flt(total * flt(me.frm.doc.additional_discount_percentage) / 100, precision("discount_amount"));
-			me.wrapper.find('input.discount-amount').val(me.frm.doc.discount_amount)
 			me.refresh();
+			me.wrapper.find('input.discount-amount').val(me.frm.doc.discount_amount)
 		});
 
 		this.wrapper.find('input.discount-amount').on("change", function () {
 			me.frm.doc.discount_amount = flt($(this).val(), precision("discount_amount"));
 			me.frm.doc.additional_discount_percentage = 0.0;
-			me.wrapper.find('input.discount-percentage').val(0);
 			me.refresh();
+			me.wrapper.find('input.discount-percentage').val(0);
 		});
 	},
 
@@ -1517,6 +1523,8 @@
 		var me = this;
 		this.wrapper.find(".net-total").text(format_currency(me.frm.doc.total, me.frm.doc.currency));
 		this.wrapper.find(".grand-total").text(format_currency(me.frm.doc.grand_total, me.frm.doc.currency));
+		this.wrapper.find('input.discount-percentage').val(this.frm.doc.additional_discount_percentage);
+		this.wrapper.find('input.discount-amount').val(this.frm.doc.discount_amount);
 	},
 
 	set_primary_action: function () {
diff --git a/erpnext/patches/v8_0/disable_instructor_role.py b/erpnext/patches/v8_0/disable_instructor_role.py
index 94ebd9c..4ba78d1 100644
--- a/erpnext/patches/v8_0/disable_instructor_role.py
+++ b/erpnext/patches/v8_0/disable_instructor_role.py
@@ -12,6 +12,7 @@
 
 	domains = frappe.db.sql_list("select domain from tabCompany")
 	if "Education" not in domains:
-		role = frappe.get_doc("Role", "Instructor")
-		role.disabled = 1
-		role.save(ignore_permissions=True)
\ No newline at end of file
+		if frappe.db.exists("Role", "Instructor"):
+			role = frappe.get_doc("Role", "Instructor")
+			role.disabled = 1
+			role.save(ignore_permissions=True)
\ No newline at end of file