set POS Invoice format only if its enabled (#15326)

diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index a14c234..4ec97c4 100755
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -12,7 +12,7 @@
 from erpnext.stock.get_item_details import get_pos_profile
 from frappe import _
 from frappe.core.doctype.communication.email import make
-from frappe.utils import nowdate
+from frappe.utils import nowdate, cint
 
 from six import string_types, iteritems
 
@@ -514,7 +514,7 @@
 		name = frappe.db.get_value('Sales Invoice', {'offline_pos_name': key}, 'name')
 		data = json.loads(data)
 		sender = frappe.session.user
-		print_format = "POS Invoice"
+		print_format = "POS Invoice" if not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')) else None
 		attachments = [frappe.attach_print('Sales Invoice', name, print_format=print_format)]
 
 		make(subject=data.get('subject'), content=data.get('content'), recipients=data.get('recipients'),
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 53d0fda..2688b4f 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -289,9 +289,13 @@
 
 		super(SalesInvoice, self).set_missing_values(for_validate)
 
+		print_format = pos.get("print_format_for_online")
+		if not print_format and not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')):
+			print_format = 'POS Invoice'
+
 		if pos:
 			return {
-				"print_format": pos.get("print_format_for_online"),
+				"print_format": print_format,
 				"allow_edit_rate": pos.get("allow_user_to_edit_rate"),
 				"allow_edit_discount": pos.get("allow_user_to_edit_discount")
 			}
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index da72dc5..a6f7a28 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -519,7 +519,7 @@
 					this.frm.cscript.calculate_taxes_and_totals();
 
 					if (r.message) {
-						this.frm.meta.default_print_format = r.message.print_format || 'POS Invoice';
+						this.frm.meta.default_print_format = r.message.print_format || "";
 						this.frm.allow_edit_rate = r.message.allow_edit_rate;
 						this.frm.allow_edit_discount = r.message.allow_edit_discount;
 					}