[enhancement] POS print after save #385:wq:wq
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.js b/erpnext/accounts/doctype/pos_profile/pos_profile.js
index 83643fe..da49036 100755
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.js
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.js
@@ -6,6 +6,14 @@
 		return { filter: { selling: 1 } };
 	});
 
+	frm.set_query("print_format", function() {
+		return { filter: { doc_type: "Sales Invoice" } };
+	});
+
+	erpnext.queries.setup_queries(frm, "Warehouse", function() {
+		return erpnext.queries.warehouse(frm.doc);
+	});
+
 	frm.call({
 		method: "erpnext.accounts.doctype.pos_profile.pos_profile.get_series",
 		callback: function(r) {
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json
index 9e79590..084c102 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.json
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json
@@ -1,37 +1,42 @@
 {
+ "allow_copy": 0, 
+ "allow_import": 0, 
  "allow_rename": 0, 
  "autoname": "hash", 
  "creation": "2013-05-24 12:15:51", 
+ "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "fields": [
   {
+   "allow_on_submit": 0, 
    "fieldname": "user", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
    "in_list_view": 1, 
-   "label": "User", 
+   "label": "Applicable for User", 
+   "no_copy": 0, 
    "oldfieldname": "user", 
    "oldfieldtype": "Link", 
    "options": "User", 
    "permlevel": 0, 
-   "read_only": 0
-  }, 
-  {
-   "description": "", 
-   "fieldname": "territory", 
-   "fieldtype": "Link", 
-   "in_list_view": 1, 
-   "label": "Territory", 
-   "oldfieldname": "territory", 
-   "oldfieldtype": "Link", 
-   "options": "Territory", 
-   "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "naming_series", 
    "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Series", 
    "no_copy": 1, 
@@ -39,232 +44,581 @@
    "oldfieldtype": "Select", 
    "options": "[Select]", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 1
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
-   "fieldname": "currency", 
-   "fieldtype": "Link", 
-   "in_list_view": 0, 
-   "label": "Currency", 
-   "oldfieldname": "currency", 
-   "oldfieldtype": "Select", 
-   "options": "Currency", 
-   "permlevel": 0, 
-   "read_only": 0, 
-   "reqd": 1
-  }, 
-  {
-   "fieldname": "selling_price_list", 
-   "fieldtype": "Link", 
-   "label": "Price List", 
-   "oldfieldname": "price_list_name", 
-   "oldfieldtype": "Select", 
-   "options": "Price List", 
-   "permlevel": 0, 
-   "read_only": 0, 
-   "reqd": 0
-  }, 
-  {
-   "fieldname": "company", 
-   "fieldtype": "Link", 
-   "in_list_view": 1, 
-   "label": "Company", 
-   "oldfieldname": "company", 
-   "oldfieldtype": "Link", 
-   "options": "Company", 
-   "permlevel": 0, 
-   "read_only": 0, 
-   "reqd": 1
-  }, 
-  {
+   "allow_on_submit": 0, 
    "fieldname": "warehouse", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Warehouse", 
+   "no_copy": 0, 
    "oldfieldname": "warehouse", 
    "oldfieldtype": "Link", 
    "options": "Warehouse", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "default": "1", 
+   "description": "", 
+   "fieldname": "update_stock", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Update Stock", 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "column_break_4", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "customer", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Customer", 
+   "no_copy": 0, 
+   "oldfieldname": "customer_account", 
+   "oldfieldtype": "Link", 
+   "options": "Customer", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Company", 
+   "no_copy": 0, 
+   "oldfieldname": "company", 
+   "oldfieldtype": "Link", 
+   "options": "Company", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "currency", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Currency", 
+   "no_copy": 0, 
+   "oldfieldname": "currency", 
+   "oldfieldtype": "Select", 
+   "options": "Currency", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "mode_of_payment", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Mode of Payment", 
+   "no_copy": 0, 
+   "options": "Mode of Payment", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "section_break_16", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "print_format", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Print Format", 
+   "no_copy": 0, 
+   "options": "Print Format", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 1, 
    "fieldname": "letter_head", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Letter Head", 
+   "no_copy": 0, 
    "oldfieldname": "letter_head", 
    "oldfieldtype": "Select", 
    "options": "Letter Head", 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 0
-  }, 
-  {
-   "fieldname": "tc_name", 
-   "fieldtype": "Link", 
-   "label": "Terms and Conditions", 
-   "oldfieldname": "tc_name", 
-   "oldfieldtype": "Link", 
-   "options": "Terms and Conditions", 
-   "permlevel": 0, 
-   "read_only": 0
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 1, 
    "fieldname": "select_print_heading", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Print Heading", 
+   "no_copy": 0, 
    "oldfieldname": "select_print_heading", 
    "oldfieldtype": "Select", 
    "options": "Print Heading", 
    "permlevel": 0, 
-   "read_only": 0
-  }, 
-  {
-   "fieldname": "column_break0", 
-   "fieldtype": "Column Break", 
-   "oldfieldtype": "Column Break", 
-   "permlevel": 0, 
-   "read_only": 0
-  }, 
-  {
-   "default": "1", 
-   "description": "Create Stock Ledger Entries when you submit a Sales Invoice", 
-   "fieldname": "update_stock", 
-   "fieldtype": "Check", 
-   "label": "Update Stock", 
-   "permlevel": 0, 
-   "reqd": 0
-  }, 
-  {
-   "fieldname": "customer", 
-   "fieldtype": "Link", 
-   "in_list_view": 0, 
-   "label": "Customer", 
-   "oldfieldname": "customer_account", 
-   "oldfieldtype": "Link", 
-   "options": "Customer", 
-   "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
-   "fieldname": "mode_of_payment", 
-   "fieldtype": "Link", 
-   "label": "Mode of Payment", 
-   "options": "Mode of Payment", 
-   "permlevel": 0, 
-   "precision": ""
-  }, 
-  {
-   "fieldname": "cash_bank_account", 
-   "fieldtype": "Link", 
-   "label": "Cash/Bank Account", 
-   "oldfieldname": "cash_bank_account", 
-   "oldfieldtype": "Link", 
-   "options": "Account", 
-   "permlevel": 0, 
-   "read_only": 0, 
-   "reqd": 0
-  }, 
-  {
-   "fieldname": "income_account", 
-   "fieldtype": "Link", 
-   "label": "Income Account", 
-   "oldfieldname": "income_account", 
-   "oldfieldtype": "Link", 
-   "options": "Account", 
-   "permlevel": 0, 
-   "read_only": 0, 
-   "reqd": 0
-  }, 
-  {
-   "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
-   "fieldname": "expense_account", 
+   "allow_on_submit": 0, 
+   "fieldname": "tc_name", 
    "fieldtype": "Link", 
    "hidden": 0, 
-   "label": "Expense Account", 
-   "options": "Account", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 0, 
-   "reqd": 0
-  }, 
-  {
-   "fieldname": "cost_center", 
-   "fieldtype": "Link", 
-   "label": "Cost Center", 
-   "oldfieldname": "cost_center", 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Terms and Conditions", 
+   "no_copy": 0, 
+   "oldfieldname": "tc_name", 
    "oldfieldtype": "Link", 
-   "options": "Cost Center", 
+   "options": "Terms and Conditions", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "fieldname": "column_break0", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "oldfieldtype": "Column Break", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "description": "", 
+   "fieldname": "territory", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "label": "Territory", 
+   "no_copy": 0, 
+   "oldfieldname": "territory", 
+   "oldfieldtype": "Link", 
+   "options": "Territory", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "selling_price_list", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Price List", 
+   "no_copy": 0, 
+   "oldfieldname": "price_list_name", 
+   "oldfieldtype": "Select", 
+   "options": "Price List", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "section_break_19", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "fieldname": "write_off_account", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Write Off Account", 
+   "no_copy": 0, 
    "options": "Account", 
    "permlevel": 0, 
    "precision": "", 
-   "reqd": 1
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "write_off_cost_center", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Write Off Cost Center", 
+   "no_copy": 0, 
    "options": "Cost Center", 
    "permlevel": 0, 
    "precision": "", 
-   "reqd": 1
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "taxes_and_charges", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Taxes and Charges", 
+   "no_copy": 0, 
    "oldfieldname": "charge", 
    "oldfieldtype": "Link", 
    "options": "Sales Taxes and Charges Template", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "column_break_23", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "cash_bank_account", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Cash/Bank Account", 
+   "no_copy": 0, 
+   "oldfieldname": "cash_bank_account", 
+   "oldfieldtype": "Link", 
+   "options": "Account", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "income_account", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Income Account", 
+   "no_copy": 0, 
+   "oldfieldname": "income_account", 
+   "oldfieldtype": "Link", 
+   "options": "Account", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
+   "fieldname": "expense_account", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Expense Account", 
+   "no_copy": 0, 
+   "options": "Account", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "cost_center", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Cost Center", 
+   "no_copy": 0, 
+   "oldfieldname": "cost_center", 
+   "oldfieldtype": "Link", 
+   "options": "Cost Center", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }
  ], 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
  "icon": "icon-cog", 
  "idx": 1, 
- "modified": "2015-07-28 15:07:14.417200", 
+ "in_create": 0, 
+ "in_dialog": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
+ "istable": 0, 
+ "modified": "2015-08-18 17:49:09.098876", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "POS Profile", 
  "owner": "Administrator", 
  "permissions": [
   {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
    "create": 1, 
    "delete": 1, 
    "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
    "role": "Accounts Manager", 
+   "set_user_permissions": 0, 
    "share": 1, 
    "submit": 0, 
    "write": 1
   }, 
   {
+   "amend": 0, 
    "apply_user_permissions": 1, 
+   "cancel": 0, 
+   "create": 0, 
    "delete": 0, 
    "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
    "role": "Accounts User", 
-   "submit": 0
+   "set_user_permissions": 0, 
+   "share": 0, 
+   "submit": 0, 
+   "write": 0
   }
  ], 
+ "read_only": 0, 
+ "read_only_onload": 0, 
  "sort_field": "modified", 
  "sort_order": "DESC", 
  "title_field": "user"
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index caf741e..dd42f45 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -28,12 +28,9 @@
 			}
 		}
 
-		// if document is POS then change default print format to "POS Invoice" if no default is specified
-		if(cur_frm.doc.is_pos && cur_frm.doc.docstatus===1 && cint(frappe.defaults.get_user_defaults("fs_pos_view"))===1
-			&& !locals.DocType[cur_frm.doctype].default_print_format) {
-			locals.DocType[cur_frm.doctype].default_print_format = "POS Invoice";
-			cur_frm.setup_print_layout();
-		}
+		erpnext.queries.setup_queries(this.frm, "Warehouse", function() {
+			return erpnext.queries.warehouse(me.frm.doc);
+		});
 	},
 
 	refresh: function(doc, dt, dn) {
@@ -74,6 +71,23 @@
 			cur_frm.cscript.sales_order_btn();
 			cur_frm.cscript.delivery_note_btn();
 		}
+
+		this.set_default_print_format();
+	},
+
+	set_default_print_format: function() {
+		// set default print format to POS type
+		if(cur_frm.doc.is_pos) {
+			if(cur_frm.pos_print_format) {
+				cur_frm.meta._default_print_format = cur_frm.meta.default_print_format;
+				cur_frm.meta.default_print_format = cur_frm.pos_print_format;
+			}
+		} else {
+			if(cur_frm.meta.cur_frm.meta._default_print_format) {
+				cur_frm.meta.default_print_format = cur_frm.meta._default_print_format;
+				cur_frm.meta._default_print_format = null;
+			}
+		}
 	},
 
 	sales_order_btn: function() {
@@ -118,6 +132,7 @@
 	},
 
 	is_pos: function(doc, dt, dn, callback_fn) {
+		if(cur_frm.doc.__missing_values_set) return;
 		cur_frm.cscript.hide_fields(this.frm.doc);
 		if(cint(this.frm.doc.is_pos)) {
 			if(!this.frm.doc.company) {
@@ -130,6 +145,8 @@
 					method: "set_missing_values",
 					callback: function(r) {
 						if(!r.exc) {
+							cur_frm.pos_print_format = r.message.print_format;
+							cur_frm.doc.__missing_values_set = true;
 							me.frm.script_manager.trigger("update_stock");
 							frappe.model.set_default_values(me.frm.doc);
 							me.set_dynamic_labels();
@@ -376,10 +393,13 @@
 		if(row.delivery_note) frappe.model.clear_doc("Delivery Note", row.delivery_note)
 	})
 
-	if(cint(frappe.boot.notification_settings.sales_invoice)) {
+	if(cur_frm.doc.is_pos) {
+		frappe.msgprint('<a class="btn btn-primary" \
+			onclick="cur_frm.print_preview.printit(true)" style="margin-right: 5px;">Print</a>\
+			<a class="btn btn-default" href="#Form/Sales Invoice/New">New</a>');
+
+	} else if(cint(frappe.boot.notification_settings.sales_invoice)) {
 		cur_frm.email_doc(frappe.boot.notification_settings.sales_invoice_message);
-	} else if(cur_frm.doc.is_pos) {
-		new_doc("Sales Invoice");
 	}
 }
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 4285eb8..f82590a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -139,7 +139,7 @@
 			})
 
 	def set_missing_values(self, for_validate=False):
-		self.set_pos_fields(for_validate)
+		pos = self.set_pos_fields(for_validate)
 
 		if not self.debit_to:
 			self.debit_to = get_party_account(self.company, self.customer, "Customer")
@@ -148,6 +148,9 @@
 
 		super(SalesInvoice, self).set_missing_values(for_validate)
 
+		if pos:
+			return {"print_format": pos.get("print_format") }
+
 	def update_time_log_batch(self, sales_invoice):
 		for d in self.get("items"):
 			if d.time_log_batch:
@@ -168,8 +171,8 @@
 		if cint(self.is_pos) != 1:
 			return
 
-		from erpnext.stock.get_item_details import get_pos_profiles_item_details, get_pos_profiles
-		pos = get_pos_profiles(self.company)
+		from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile
+		pos = get_pos_profile(self.company)
 
 		if pos:
 			if not for_validate and not self.customer:
@@ -189,7 +192,7 @@
 			# set pos values in items
 			for item in self.get("items"):
 				if item.get('item_code'):
-					for fname, val in get_pos_profiles_item_details(pos,
+					for fname, val in get_pos_profile_item_details(pos,
 						frappe._dict(item.as_dict()), pos).items():
 
 						if (not for_validate) or (for_validate and not item.get(fname)):
@@ -203,6 +206,8 @@
 			if self.taxes_and_charges and not len(self.get("taxes")):
 				self.set_taxes()
 
+		return pos
+
 	def get_advances(self):
 		if not self.is_return:
 			super(SalesInvoice, self).get_advances(self.debit_to, "Customer", self.customer,
diff --git a/erpnext/change_log/current/pos.md b/erpnext/change_log/current/pos.md
new file mode 100644
index 0000000..9faf82d
--- /dev/null
+++ b/erpnext/change_log/current/pos.md
@@ -0,0 +1,2 @@
+- Set default Print Format for Point-of-Sale (POS) via **POS Profile**
+- Option to automatically print after submitting POS **Sales Invoice**
diff --git a/erpnext/public/js/pos/pos.js b/erpnext/public/js/pos/pos.js
index e28c718..5f82796 100644
--- a/erpnext/public/js/pos/pos.js
+++ b/erpnext/public/js/pos/pos.js
@@ -182,6 +182,9 @@
 			child.serial_no = serial_no;
 
 		this.frm.script_manager.trigger("item_code", child.doctype, child.name);
+		frappe.after_ajax(function() {
+			me.frm.script_manager.trigger("qty", child.doctype, child.name);
+		})
 	},
 	refresh_search_box: function() {
 		var me = this;
@@ -432,7 +435,7 @@
 							}
 						},
 						{fieldtype:'Currency', fieldname:'write_off_amount',
-							label: __('Write Off'), default: 0.0, hidden: 1},
+							label: __('Write Off'), "default": 0.0, hidden: 1},
 					]
 				});
 				me.dialog = dialog;
@@ -470,6 +473,8 @@
 			}
 			me.frm.set_value("mode_of_payment", values.mode_of_payment);
 
+			//me.frm.cscript.calculate_taxes_and_totals();
+
 			var paid_amount = flt((flt(values.paid_amount) - flt(values.change)) / me.frm.doc.conversion_rate, precision("paid_amount"));
 			me.frm.set_value("paid_amount", paid_amount);
 
@@ -479,7 +484,6 @@
 
 			me.frm.savesubmit(this);
 			dialog.hide();
-			me.refresh();
 		})
 
 	}
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index a57dd59..d08c63c 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -50,7 +50,7 @@
 	get_price_list_rate(args, item_doc, out)
 
 	if args.transaction_type == "selling" and cint(args.is_pos):
-		out.update(get_pos_profiles_item_details(args.company, args))
+		out.update(get_pos_profile_item_details(args.company, args))
 
 	# update args with out, if key or value not exists
 	for key, value in out.iteritems():
@@ -284,16 +284,16 @@
 		item_supplier = item_doc.get("supplier_items", {"supplier": args.supplier})
 		out.supplier_part_no = item_supplier[0].supplier_part_no if item_supplier else None
 
-def get_pos_profiles_item_details(company, args, pos_profiles=None):
+def get_pos_profile_item_details(company, args, pos_profile=None):
 	res = frappe._dict()
 
-	if not pos_profiles:
-		pos_profiles = get_pos_profiles(company)
+	if not pos_profile:
+		pos_profile = get_pos_profile(company)
 
-	if pos_profiles:
+	if pos_profile:
 		for fieldname in ("income_account", "cost_center", "warehouse", "expense_account"):
-			if not args.get(fieldname) and pos_profiles.get(fieldname):
-				res[fieldname] = pos_profiles.get(fieldname)
+			if not args.get(fieldname) and pos_profile.get(fieldname):
+				res[fieldname] = pos_profile.get(fieldname)
 
 		if res.get("warehouse"):
 			res.actual_qty = get_available_qty(args.item_code,
@@ -301,15 +301,16 @@
 
 	return res
 
-def get_pos_profiles(company):
-	pos_profiles = frappe.db.sql("""select * from `tabPOS Profile` where user = %s
+@frappe.whitelist()
+def get_pos_profile(company):
+	pos_profile = frappe.db.sql("""select * from `tabPOS Profile` where user = %s
 		and company = %s""", (frappe.session['user'], company), as_dict=1)
 
-	if not pos_profiles:
-		pos_profiles = frappe.db.sql("""select * from `tabPOS Profile`
+	if not pos_profile:
+		pos_profile = frappe.db.sql("""select * from `tabPOS Profile`
 			where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
 
-	return pos_profiles and pos_profiles[0] or None
+	return pos_profile and pos_profile[0] or None
 
 
 def get_serial_nos_by_fifo(args, item_doc):