Merge pull request #7662 from nick9822/patch-2

Sales analytics error after upgrade
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index d916789..dcc072d 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.2.18'
+__version__ = '7.2.19'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index abc6eba..11dcfe7 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -74,6 +74,9 @@
 		clearance_date_updated = False
 		for d in self.get('payment_entries'):
 			if d.clearance_date:
+				if not d.payment_document:
+					frappe.throw(_("Row #{0}: Payment document is required to complete the trasaction"))
+
 				if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
 					frappe.throw(_("Row #{0}: Clearance date {1} cannot be before Cheque Date {2}")
 						.format(d.idx, d.clearance_date, d.cheque_date))
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.json b/erpnext/accounts/doctype/cost_center/cost_center.json
index f590b5d..9aaaed2 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.json
+++ b/erpnext/accounts/doctype/cost_center/cost_center.json
@@ -278,14 +278,14 @@
  "icon": "fa fa-money", 
  "idx": 1, 
  "image_view": 0, 
- "in_create": 1, 
+ "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-11-07 05:20:40.282432", 
+ "modified": "2017-01-30 11:27:36.615323", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Cost Center", 
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index a13cc7d..0cf34dd 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -46,6 +46,9 @@
 		self.accounts = [account for account in self.accounts
 			if not (account.debit_in_account_currency==0.0 and account.credit_in_account_currency==0.0)]
 
+		if not self.accounts:
+			frappe.throw("Debit or Credit amount is not found in account table")
+
 	def on_submit(self):
 		self.check_credit_limit()
 		self.make_gl_entries()
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
index 5a3e651..03bb7ae 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
@@ -91,8 +91,8 @@
 }
 
 //Dynamically change the description based on type of margin
-cur_frm.cscript.type = function(doc){
-	cur_frm.set_df_property('rate', 'description', doc.type=='Percentage'?'In Percentage %':'In Amount')
+cur_frm.cscript.margin_type = function(doc){
+	cur_frm.set_df_property('margin_rate_or_amount', 'description', doc.margin_type=='Percentage'?'In Percentage %':'In Amount')
 }
 
 frappe.ui.form.on('Pricing Rule', 'price_or_discount', function(frm){
@@ -112,4 +112,4 @@
 			}
 		}
 	}
-})
\ No newline at end of file
+})
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 3c62297..c5d2b31 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -123,12 +123,13 @@
 	
 def get_serial_no_for_item(args):
 	from erpnext.stock.get_item_details import get_serial_no
+
 	item_details = frappe._dict({
 		"doctype": args.doctype,
 		"name": args.name,
 		"serial_no": args.serial_no
 	})
-	if args.get("parenttype") in ("Sales Invoice", "Delivery Note"):
+	if args.get("parenttype") in ("Sales Invoice", "Delivery Note") and args.qty > 0:
 		item_details.serial_no = get_serial_no(args)
 	return item_details
 
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index 6f8e219..a91d974 100755
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -1316,6 +1316,34 @@
    "unique": 0
   }, 
   {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "is_sample_item", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Sample Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1788,7 +1816,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-11-16 16:04:52.465169", 
+ "modified": "2017-02-07 01:21:03.737800", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice Item", 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index f026cb0..4fb3dba 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -6,7 +6,7 @@
  "beta": 0, 
  "creation": "2013-05-24 19:29:05", 
  "custom": 0, 
- "default_print_format": "Standard", 
+ "default_print_format": "Sample Print", 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "", 
@@ -22,13 +22,12 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "icon-user", 
+   "options": "fa fa-user", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -51,7 +50,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Title", 
@@ -79,7 +77,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Series", 
@@ -109,7 +106,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 1, 
    "label": "Customer", 
@@ -140,7 +136,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Customer Name", 
@@ -169,7 +164,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Is POS", 
@@ -199,7 +193,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Is Return", 
@@ -227,12 +220,11 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Offline POS Name", 
    "length": 0, 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -255,7 +247,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -283,7 +274,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Date", 
@@ -312,7 +302,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Payment Due Date", 
@@ -341,7 +330,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Company", 
@@ -371,7 +359,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Project", 
@@ -401,7 +388,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 1, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Amended From", 
@@ -432,7 +418,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Return Against Sales Invoice", 
@@ -462,7 +447,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Address and Contact", 
@@ -490,7 +474,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Customer Address", 
@@ -518,7 +501,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Address", 
@@ -545,7 +527,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Contact Person", 
@@ -573,7 +554,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Contact", 
@@ -600,7 +580,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Mobile No", 
@@ -627,7 +606,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Contact Email", 
@@ -655,7 +633,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -682,7 +659,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Shipping Address Name", 
@@ -711,7 +687,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Shipping Address", 
@@ -740,7 +715,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Customer Group", 
@@ -768,7 +742,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Territory", 
@@ -777,7 +750,7 @@
    "options": "Territory", 
    "permlevel": 0, 
    "precision": "", 
-   "print_hide": 0, 
+   "print_hide": 1, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "remember_last_selected_value": 0, 
@@ -798,7 +771,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Currency and Price List", 
@@ -826,7 +798,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Currency", 
@@ -857,7 +828,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Exchange Rate", 
@@ -887,7 +857,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -914,7 +883,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Price List", 
@@ -944,7 +912,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Price List Currency", 
@@ -973,7 +940,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Price List Exchange Rate", 
@@ -1001,7 +967,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Ignore Pricing Rule", 
@@ -1028,14 +993,13 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "icon-shopping-cart", 
+   "options": "fa fa-shopping-cart", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -1057,7 +1021,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Update Stock", 
@@ -1086,7 +1049,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Items", 
@@ -1116,13 +1078,12 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Packing List", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "icon-suitcase", 
+   "options": "fa fa-suitcase", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -1144,7 +1105,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Packed Items", 
@@ -1172,7 +1132,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Product Bundle Help", 
@@ -1201,7 +1160,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Time Sheet List", 
@@ -1229,7 +1187,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Time Sheets", 
@@ -1259,7 +1216,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Billing Amount", 
@@ -1287,7 +1243,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1313,7 +1268,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total (Company Currency)", 
@@ -1342,7 +1296,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Net Total (Company Currency)", 
@@ -1372,7 +1325,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1398,7 +1350,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Net Total", 
@@ -1426,7 +1377,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total", 
@@ -1455,14 +1405,13 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "icon-money", 
+   "options": "fa fa-money", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -1484,7 +1433,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Taxes and Charges", 
@@ -1514,7 +1462,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1540,7 +1487,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Shipping Rule", 
@@ -1569,7 +1515,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1595,7 +1540,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Sales Taxes and Charges", 
@@ -1625,7 +1569,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Taxes and Charges Calculation", 
@@ -1653,7 +1596,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1679,7 +1621,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Taxes and Charges (Company Currency)", 
@@ -1709,7 +1650,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1736,7 +1676,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Taxes and Charges", 
@@ -1765,7 +1704,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Additional Discount", 
@@ -1794,7 +1732,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Apply Additional Discount On", 
@@ -1823,7 +1760,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Additional Discount Amount (Company Currency)", 
@@ -1852,7 +1788,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -1878,7 +1813,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Additional Discount Percentage", 
@@ -1906,7 +1840,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Additional Discount Amount", 
@@ -1934,14 +1867,13 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "icon-money", 
+   "options": "fa fa-money", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -1963,7 +1895,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Grand Total (Company Currency)", 
@@ -1993,7 +1924,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Rounded Total (Company Currency)", 
@@ -2024,7 +1954,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "In Words (Company Currency)", 
@@ -2053,7 +1982,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -2081,7 +2009,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Grand Total", 
@@ -2111,7 +2038,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Rounded Total", 
@@ -2141,7 +2067,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "In Words", 
@@ -2170,7 +2095,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Advance", 
@@ -2200,7 +2124,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 1, 
    "label": "Outstanding Amount", 
@@ -2231,14 +2154,13 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Advance Payments", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "icon-money", 
+   "options": "fa fa-money", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -2260,7 +2182,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Get Advances Received", 
@@ -2289,7 +2210,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Advances", 
@@ -2321,13 +2241,12 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Payments", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "icon-money", 
+   "options": "fa fa-money", 
    "permlevel": 0, 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
@@ -2350,7 +2269,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Cash/Bank Account", 
@@ -2380,7 +2298,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Sales Invoice Payment", 
@@ -2409,7 +2326,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -2436,7 +2352,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Paid Amount (Company Currency)", 
@@ -2465,7 +2380,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -2493,7 +2407,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Paid Amount", 
@@ -2523,7 +2436,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -2550,7 +2462,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Base Change Amount (Company Currency)", 
@@ -2579,7 +2490,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -2606,7 +2516,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Change Amount", 
@@ -2635,7 +2544,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Account for Change Amount", 
@@ -2666,7 +2574,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Write Off", 
@@ -2695,7 +2602,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Write Off Amount", 
@@ -2723,7 +2629,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Write Off Amount (Company Currency)", 
@@ -2753,7 +2658,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Write Off Outstanding Amount", 
@@ -2781,7 +2685,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -2809,7 +2712,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Write Off Account", 
@@ -2838,7 +2740,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Write Off Cost Center", 
@@ -2867,7 +2768,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Terms", 
@@ -2896,7 +2796,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Terms", 
@@ -2926,7 +2825,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Terms and Conditions Details", 
@@ -2955,7 +2853,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Printing Settings", 
@@ -2983,7 +2880,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Letter Head", 
@@ -3013,7 +2909,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Print Language", 
@@ -3041,7 +2936,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -3068,7 +2962,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Print Heading", 
@@ -3099,7 +2992,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "More Information", 
@@ -3128,7 +3020,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Campaign", 
@@ -3158,7 +3049,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -3186,7 +3076,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Status", 
@@ -3215,7 +3104,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Source", 
@@ -3245,14 +3133,13 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Accounting Details", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "icon-file-text", 
+   "options": "fa fa-file-text", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -3275,7 +3162,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Debit To", 
@@ -3305,7 +3191,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Party Account Currency", 
@@ -3336,7 +3221,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Is Opening Entry", 
@@ -3366,7 +3250,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "C-Form Applicable", 
@@ -3394,7 +3277,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "C-Form No", 
@@ -3422,7 +3304,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -3449,7 +3330,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Posting Time", 
@@ -3478,7 +3358,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Remarks", 
@@ -3508,14 +3387,13 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Commission", 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Section Break", 
-   "options": "icon-group", 
+   "options": "fa fa-group", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -3537,7 +3415,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 1, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Sales Partner", 
@@ -3567,7 +3444,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -3595,7 +3471,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Commission Rate (%)", 
@@ -3624,7 +3499,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Total Commission", 
@@ -3655,7 +3529,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Sales Team", 
@@ -3682,7 +3555,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Sales Team1", 
@@ -3714,13 +3586,12 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Recurring", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "icon-time", 
+   "options": "fa fa-time", 
    "permlevel": 0, 
    "print_hide": 1, 
    "print_hide_if_no_value": 0, 
@@ -3742,7 +3613,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Settings", 
@@ -3772,7 +3642,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Is Recurring", 
@@ -3801,7 +3670,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Reference Document", 
@@ -3831,7 +3699,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Frequency", 
@@ -3861,7 +3728,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Repeat on Day of Month", 
@@ -3890,7 +3756,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "End Date", 
@@ -3918,7 +3783,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Submit on creation", 
@@ -3948,7 +3812,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Notify by email", 
@@ -3978,7 +3841,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Notification Email Address", 
@@ -4007,7 +3869,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Recurring Print Format", 
@@ -4036,7 +3897,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "This Document", 
@@ -4066,7 +3926,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "From Date", 
@@ -4095,7 +3954,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "To Date", 
@@ -4124,7 +3982,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Next Date", 
@@ -4151,7 +4008,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Against Income Account", 
@@ -4173,7 +4029,7 @@
  ], 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
- "icon": "icon-file-text", 
+ "icon": "fa fa-file-text", 
  "idx": 181, 
  "image_view": 0, 
  "in_create": 0, 
@@ -4183,7 +4039,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-01-18 13:21:13.226318", 
+ "modified": "2017-02-02 17:03:01.892758", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice", 
@@ -4199,7 +4055,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -4220,7 +4075,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -4241,7 +4095,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 1, 
    "print": 0, 
    "read": 1, 
@@ -4262,7 +4115,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 1, 
    "print": 0, 
    "read": 1, 
@@ -4282,6 +4134,6 @@
  "sort_order": "DESC", 
  "timeline_field": "customer", 
  "title_field": "title", 
- "track_changes": 1, 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
index 944230b..bf6d986 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
@@ -1382,6 +1382,34 @@
    "unique": 0
   }, 
   {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "is_sample_item", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Sample Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1882,7 +1910,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-11-16 16:04:02.438952", 
+ "modified": "2017-02-07 01:21:47.142162", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice Item", 
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index 3451238..df6cb3c 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _, scrub
+from erpnext.stock.utils import get_incoming_rate
 from frappe.utils import flt
 
 
@@ -208,21 +209,18 @@
 								flt(my_sle[i+1].stock_value) or 0.0
 							return  previous_stock_value - flt(sle.stock_value)
 			else:
-				return flt(row.qty) * self.get_average_buying_rate(item_code)
-
+				return flt(row.qty) * self.get_average_buying_rate(row, item_code)
 
 		return 0.0
 
-	def get_average_buying_rate(self, item_code):
+	def get_average_buying_rate(self, row, item_code):
 		if not item_code in self.average_buying_rate:
 			if item_code in self.non_stock_items:
 				self.average_buying_rate[item_code] = flt(frappe.db.sql("""select sum(base_net_amount) / sum(qty * conversion_factor)
 					from `tabPurchase Invoice Item`
 					where item_code = %s and docstatus=1""", item_code)[0][0])
 			else:
-				self.average_buying_rate[item_code] = flt(frappe.db.sql("""select avg(valuation_rate)
-					from `tabStock Ledger Entry`
-					where item_code = %s and qty_after_transaction > 0""", item_code)[0][0])
+				self.average_buying_rate[item_code] = get_incoming_rate(row)
 
 		return self.average_buying_rate[item_code]
 
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
index 09ba40c..c0a4212 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.py
@@ -11,9 +11,11 @@
 value_fields = ("income", "expense", "gross_profit_loss")
 
 def execute(filters=None):
+	if not filters.get('based_on'): filters["based_on"] = 'Cost Center'
+
 	based_on = filters.based_on.replace(' ', '_').lower()
 	validate_filters(filters)
-	accounts = get_accounts_data(based_on, filters.company)
+	accounts = get_accounts_data(based_on, filters.get("company"))
 	data = get_data(accounts, filters, based_on)
 	columns = get_columns(filters)
 	return columns, data
@@ -27,14 +29,14 @@
 
 def get_data(accounts, filters, based_on):
 	if not accounts:
-		return None
+		return []
 
 	accounts, accounts_by_name, parent_children_map = filter_accounts(accounts)
 
 	gl_entries_by_account = {}
 
-	set_gl_entries_by_account(filters.company, filters.from_date,
-		filters.to_date, based_on, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry))
+	set_gl_entries_by_account(filters.get("company"), filters.get("from_date"),
+		filters.get("to_date"), based_on, gl_entries_by_account, ignore_closing_entries=not flt(filters.get("with_period_closing_entry")))
 
 	total_row = calculate_values(accounts, gl_entries_by_account, filters)
 	accumulate_values_into_parents(accounts, accounts_by_name)
@@ -90,7 +92,7 @@
 
 def prepare_data(accounts, filters, total_row, parent_children_map, based_on):
 	data = []
-	company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
+	company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency")
 
 	for d in accounts:
 		has_value = False
@@ -99,7 +101,7 @@
 			"account": d.name,
 			"parent_account": d.parent_account,
 			"indent": d.indent,
-			"fiscal_year": filters.fiscal_year,
+			"fiscal_year": filters.get("fiscal_year"),
 			"currency": company_currency,
 			"based_on": based_on
 		}
@@ -122,9 +124,9 @@
 	return [
 		{
 			"fieldname": "account",
-			"label": _(filters.based_on),
+			"label": _(filters.get("based_on")),
 			"fieldtype": "Link",
-			"options": filters.based_on,
+			"options": filters.get("based_on"),
 			"width": 300
 		},
 		{
diff --git a/erpnext/config/learn.py b/erpnext/config/learn.py
index 426449b..86db808 100644
--- a/erpnext/config/learn.py
+++ b/erpnext/config/learn.py
@@ -44,7 +44,7 @@
 				},
 				{
 					"type": "help",
-					"label": _("Setting up Email"),
+					"label": _("Setting up Email Account"),
 					"youtube_id": "YFYe0DrB95o"
 				},
 				{
@@ -64,11 +64,6 @@
 				},
 				{
 					"type": "help",
-					"label": _("Email Account"),
-					"youtube_id": "YFYe0DrB95o"
-				},
-				{
-					"type": "help",
 					"label": _("File Manager"),
 					"youtube_id": "4-osLW3E_Rk"
 				},
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index c489008..add882c 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -54,9 +54,16 @@
 
 						self.check_expense_account(item_row)
 
-						if not sle.stock_value_difference:
-							self.update_stock_ledger_entries(sle)
-							self.validate_negative_stock(sle)
+						# If item is not a sample item 
+						# and ( valuation rate not mentioned in an incoming entry
+						# or incoming entry not found while delivering the item), 
+						# try to pick valuation rate from previous sle or Item master and update in SLE
+						# Otherwise, throw an exception
+
+						if not sle.stock_value_difference and self.doctype != "Stock Reconciliation" \
+							and not item_row.get("is_sample_item"):
+
+							sle = self.update_stock_ledger_entries(sle)
 
 						gl_list.append(self.get_gl_dict({
 							"account": warehouse_account[sle.warehouse]["name"],
@@ -89,20 +96,25 @@
 		return process_gl_map(gl_list)
 
 	def update_stock_ledger_entries(self, sle):
-		sle.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse,
-			sle.voucher_type, sle.voucher_no)
+		sle.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse, 
+			self.doctype, self.name)
+
 		sle.stock_value = flt(sle.qty_after_transaction) * flt(sle.valuation_rate)
-		sle.stock_value_difference = sle.stock_value
+		sle.stock_value_difference = flt(sle.actual_qty) * flt(sle.valuation_rate)
+		
 		if sle.name:
-			frappe.db.sql(""" update `tabStock Ledger Entry` set stock_value = %(stock_value)s,
-				valuation_rate = %(valuation_rate)s, stock_value_difference = %(stock_value_difference)s 
-				where name = %(name)s""", (sle))
-
-	def validate_negative_stock(self, sle):
-		if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
-			frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting {1} {2}")
-			.format(sle.item_code, sle.voucher_type, sle.voucher_no))
-
+			frappe.db.sql("""
+				update 
+					`tabStock Ledger Entry` 
+				set 
+					stock_value = %(stock_value)s,
+					valuation_rate = %(valuation_rate)s, 
+					stock_value_difference = %(stock_value_difference)s 
+				where 
+					name = %(name)s""", (sle))
+					
+		return sle
+					
 	def get_voucher_details(self, default_expense_account, default_cost_center, sle_map):
 		if self.doctype == "Stock Reconciliation":
 			return [frappe._dict({ "name": voucher_detail_no, "expense_account": default_expense_account,
@@ -150,10 +162,18 @@
 
 	def get_stock_ledger_details(self):
 		stock_ledger = {}
-		for sle in frappe.db.sql("""select name, warehouse, stock_value_difference,
-			voucher_detail_no, item_code, posting_date, posting_time, actual_qty, qty_after_transaction
-			from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
-			(self.doctype, self.name), as_dict=True):
+		stock_ledger_entries = frappe.db.sql("""
+			select 
+				name, warehouse, stock_value_difference, valuation_rate,
+				voucher_detail_no, item_code, posting_date, posting_time, 
+				actual_qty, qty_after_transaction
+			from
+				`tabStock Ledger Entry`
+			where
+				voucher_type=%s and voucher_no=%s
+		""", (self.doctype, self.name), as_dict=True)
+
+		for sle in stock_ledger_entries:
 				stock_ledger.setdefault(sle.voucher_detail_no, []).append(sle)
 		return stock_ledger
 
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index a268ea2..c306cbf 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -155,6 +155,9 @@
 			}
 		}}, target_doc)
 	target_doc.quotation_to = "Lead"
+	target_doc.run_method("set_missing_values")
+	target_doc.run_method("set_other_charges")
+	target_doc.run_method("calculate_taxes_and_totals")
 
 	return target_doc
 
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index 0c6a9b8..c664101 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -48,7 +48,7 @@
 		setup_complete({
 			"first_name": "Test",
 			"last_name": "User",
-			"email": "demo@erpnext.com",
+			"email": "test_demo@erpnext.com",
 			"company_tagline": 'Awesome Products and Services',
 			"password": "demo",
 			"fy_start_date": "2015-01-01",
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js
index cfb646d..128e533 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.js
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.js
@@ -10,6 +10,19 @@
 		frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
 	},
 
+	setup: function(frm) {
+		frm.set_query("payment_account", function() {
+			var account_types = ["Bank", "Cash"];
+			return {
+				filters: {
+					"account_type": ["in", account_types],
+					"is_group": 0,
+					"company": frm.doc.company
+				}
+			}
+		})
+	},
+
 	refresh: function(frm) {
 		frm.disable_save();
 	},
@@ -50,16 +63,6 @@
 				}
 			})
 		}
-	},
-	account: function(frm) {
-		var account_types = ["Bank", "Cash"];
-		return {
-			filters: {
-				"account_type": ["in", account_types],
-				"is_group": 0,
-				"company": frm.doc.company
-			}
-		}
 	}
 })
 
diff --git a/erpnext/hr/doctype/salary_component/salary_component.js b/erpnext/hr/doctype/salary_component/salary_component.js
index 3ed566e..3a2492c 100644
--- a/erpnext/hr/doctype/salary_component/salary_component.js
+++ b/erpnext/hr/doctype/salary_component/salary_component.js
@@ -2,7 +2,16 @@
 // For license information, please see license.txt
 
 frappe.ui.form.on('Salary Component', {
-	refresh: function(frm) {
-
+	setup: function(frm) {
+		frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
+			var d = locals[cdt][cdn];
+			return {
+				filters: {
+					"root_type": "Expense",
+					"is_group": 0,
+					"company": d.company
+				}
+			}
+		})
 	}
 });
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 0e2dd1b..d60cd35 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -33,8 +33,13 @@
 def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None):
 	def postprocess(source, target):
 		if employee:
+			employee_details = frappe.db.get_value("Employee", employee, 
+							["employee_name", "branch", "designation", "department"], as_dict=1)
 			target.employee = employee
-			target.employee_name = frappe.get_value("Employee",employee, "employee_name")
+			target.employee_name = employee_details.employee_name
+			target.branch = employee_details.branch
+			target.designation = employee_details.designation
+			target.department = employee_details.department
 		target.run_method('process_salary_structure')
 
 	doc = get_mapped_doc("Salary Structure", source_name, {
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index db5b66c..4692118 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -249,7 +249,7 @@
 				"wip_warehouse"			: "",
 				"fg_warehouse"			: d.warehouse,
 				"status"				: "Draft",
-				"project"			: frappe.db.get_value("Sales Order", d.sales_order, "project")
+				"project"				: frappe.db.get_value("Sales Order", d.sales_order, "project")
 			}
 
 			""" Club similar BOM and item for processing in case of Sales Orders """
@@ -345,53 +345,53 @@
 
 	def get_subitems(self,bom_wise_item_details, bom, parent_qty, include_sublevel, only_raw, supply_subs,non_stock_item=0):
 		items = frappe.db.sql("""
-			SELECT 
-				bom_item.item_code, 
+			SELECT
+				bom_item.item_code,
 				default_material_request_type,
 				ifnull(%(parent_qty)s * sum(bom_item.qty/ifnull(bom.quantity, 1)), 0) as qty,
-				item.is_sub_contracted_item as is_sub_contracted, 
+				item.is_sub_contracted_item as is_sub_contracted,
 				item.default_bom as default_bom,
-				bom_item.description as description,  
-				bom_item.stock_uom as stock_uom, 
-				item.min_order_qty as min_order_qty 
+				bom_item.description as description,
+				bom_item.stock_uom as stock_uom,
+				item.min_order_qty as min_order_qty
 			FROM
-				`tabBOM Item` bom_item, 
-				`tabBOM` bom, 
+				`tabBOM Item` bom_item,
+				`tabBOM` bom,
 				tabItem item
 			where
-				bom.name = bom_item.parent 
-				and bom.name = %(bom)s 
+				bom.name = bom_item.parent
+				and bom.name = %(bom)s
 				and bom_item.docstatus < 2
 				and bom_item.item_code = item.name
 			""" + ("and item.is_stock_item = 1", "")[non_stock_item] + """
 			group by bom_item.item_code""", {"bom": bom, "parent_qty": parent_qty}, as_dict=1)
-		
+
 		for d in items:
-			if ((d.default_material_request_type == "Purchase" 
-				and not (d.is_sub_contracted and only_raw and include_sublevel)) 
+			if ((d.default_material_request_type == "Purchase"
+				and not (d.is_sub_contracted and only_raw and include_sublevel))
 				or (d.default_material_request_type == "Manufacture" and not only_raw)):
 
 				if d.item_code in bom_wise_item_details:
 					bom_wise_item_details[d.item_code].qty = bom_wise_item_details[d.item_code].qty + d.qty
 				else:
 					bom_wise_item_details[d.item_code] = d
-			
+
 			if include_sublevel:
-				if ((d.default_material_request_type == "Purchase" and d.is_sub_contracted and supply_subs) 
+				if ((d.default_material_request_type == "Purchase" and d.is_sub_contracted and supply_subs)
 					or (d.default_material_request_type == "Manufacture")):
-					
+
 					my_qty = 0
 					projected_qty = self.get_item_projected_qty(d.item_code)
-					
+
 					if self.create_material_requests_for_all_required_qty:
 						my_qty = d.qty
 					elif (bom_wise_item_details[d.item_code].qty - d.qty) < projected_qty:
 						my_qty = bom_wise_item_details[d.item_code].qty - projected_qty
 					else:
 						my_qty = d.qty
-						
+
 					if my_qty > 0:
-						self.get_subitems(bom_wise_item_details, 
+						self.get_subitems(bom_wise_item_details,
 							d.default_bom, my_qty, include_sublevel, only_raw, supply_subs)
 
 		return bom_wise_item_details
@@ -408,12 +408,12 @@
 			item_list.append([item, self.item_dict[item][0][1], self.item_dict[item][0][2], total_qty])
 			item_qty = frappe.db.sql("""select warehouse, indented_qty, ordered_qty, actual_qty
 				from `tabBin` where item_code = %s""", item, as_dict=1)
-				
+
 			i_qty, o_qty, a_qty = 0, 0, 0
 			for w in item_qty:
 				i_qty, o_qty, a_qty = i_qty + flt(w.indented_qty), o_qty + \
 					flt(w.ordered_qty), a_qty + flt(w.actual_qty)
-					
+
 				item_list.append(['', '', '', '', w.warehouse, flt(w.indented_qty),
 					flt(w.ordered_qty), flt(w.actual_qty)])
 			if item_qty:
@@ -485,15 +485,15 @@
 	def get_item_projected_qty(self,item):
 		item_projected_qty = frappe.db.sql("""
 			select ifnull(sum(projected_qty),0) as qty
-			from `tabBin` 
+			from `tabBin`
 			where item_code = %(item_code)s and warehouse=%(warehouse)s
 		""", {
-			"item_code": item, 
+			"item_code": item,
 			"warehouse": self.purchase_request_for_warehouse
 		}, as_dict=1)
 
 		return item_projected_qty[0].qty
-		
+
 	def get_projected_qty(self):
 		items = self.item_dict.keys()
 		item_projected_qty = frappe.db.sql("""select item_code, sum(projected_qty)
diff --git a/erpnext/patches/v7_2/rename_evaluation_criteria.py b/erpnext/patches/v7_2/rename_evaluation_criteria.py
index 4239232..a45604f 100644
--- a/erpnext/patches/v7_2/rename_evaluation_criteria.py
+++ b/erpnext/patches/v7_2/rename_evaluation_criteria.py
@@ -2,23 +2,28 @@
 from frappe.model.utils.rename_field import rename_field
 
 def execute():
-    frappe.rename_doc("DocType", "Evaluation Criteria", "Assessment Criteria", force=True)
-    frappe.reload_doc("schools", "doctype", "assessment_criteria")
-    rename_field("Assessment Criteria", "evaluation_criteria", "assessment_criteria")
+	frappe.rename_doc("DocType", "Evaluation Criteria", "Assessment Criteria", force=True)
+	frappe.reload_doc("schools", "doctype", "assessment_criteria")
+	if 'evaluation_criteria' in frappe.db.get_table_columns('Assessment Criteria'):
+		rename_field("Assessment Criteria", "evaluation_criteria", "assessment_criteria")
 
-    frappe.rename_doc("DocType", "Assessment Evaluation Criteria", "Assessment Plan Criteria", force=True)
-    frappe.reload_doc("schools", "doctype", "assessment_plan_criteria")
-    rename_field("Assessment Plan Criteria", "evaluation_criteria", "assessment_criteria")
+	frappe.rename_doc("DocType", "Assessment Evaluation Criteria", "Assessment Plan Criteria", force=True)
+	frappe.reload_doc("schools", "doctype", "assessment_plan_criteria")
+	if 'evaluation_criteria' in frappe.db.get_table_columns('Assessment Plan'):
+		rename_field("Assessment Plan Criteria", "evaluation_criteria", "assessment_criteria")
 
-    frappe.reload_doc("schools", "doctype", "assessment_plan")
-    rename_field("Assessment Plan", "evaluation_criterias", "assessment_criteria")
-        
-    frappe.reload_doc("schools", "doctype", "assessment_result_detail")
-    rename_field("Assessment Result Detail", "evaluation_criteria", "assessment_criteria")
+	frappe.reload_doc("schools", "doctype", "assessment_plan")
+	rename_field("Assessment Plan", "evaluation_criterias", "assessment_criteria")
 
-    frappe.rename_doc("DocType", "Course Evaluation Criteria", "Course Assessment Criteria", force=True)
-    frappe.reload_doc("schools", "doctype", "course_assessment_criteria")
-    rename_field("Course Assessment Criteria", "evaluation_criteria", "assessment_criteria")
+	frappe.reload_doc("schools", "doctype", "assessment_result_detail")
+	if 'evaluation_criteria' in frappe.db.get_table_columns('Assessment Result Detail'):
+		rename_field("Assessment Result Detail", "evaluation_criteria", "assessment_criteria")
 
-    frappe.reload_doc("schools", "doctype", "course")
-    rename_field("Course", "evaluation_criterias", "assessment_criteria")
+	frappe.rename_doc("DocType", "Course Evaluation Criteria", "Course Assessment Criteria", force=True)
+	frappe.reload_doc("schools", "doctype", "course_assessment_criteria")
+	if 'evaluation_criteria' in frappe.db.get_table_columns('Course Assessment Criteria'):
+		rename_field("Course Assessment Criteria", "evaluation_criteria", "assessment_criteria")
+
+	frappe.reload_doc("schools", "doctype", "course")
+	if 'evaluation_criteria' in frappe.db.get_table_columns('Course'):
+		rename_field("Course", "evaluation_criterias", "assessment_criteria")
diff --git a/erpnext/projects/doctype/timesheet/timesheet_calendar.js b/erpnext/projects/doctype/timesheet/timesheet_calendar.js
index 0af1a6c..14f016a 100644
--- a/erpnext/projects/doctype/timesheet/timesheet_calendar.js
+++ b/erpnext/projects/doctype/timesheet/timesheet_calendar.js
@@ -4,7 +4,6 @@
 		"end": "end_date",
 		"name": "parent",
 		"id": "name",
-		"title": "name",
 		"allDay": "allDay",
 		"child_name": "name",
 		"title": "title"
diff --git a/erpnext/schools/doctype/assessment_criteria/assessment_criteria.json b/erpnext/schools/doctype/assessment_criteria/assessment_criteria.json
index dd6d5dd..990b22b 100644
--- a/erpnext/schools/doctype/assessment_criteria/assessment_criteria.json
+++ b/erpnext/schools/doctype/assessment_criteria/assessment_criteria.json
@@ -22,7 +22,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Assessment Criteria", 
@@ -42,7 +41,7 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "assessment_criteria_group", 
@@ -50,7 +49,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Assessment Criteria Group", 
@@ -80,7 +78,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-02-01 17:41:48.994388", 
+ "modified": "2017-02-03 05:53:39.248759", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Assessment Criteria", 
diff --git a/erpnext/schools/doctype/grading_scale/grading_scale.py b/erpnext/schools/doctype/grading_scale/grading_scale.py
index f7f6ba9..4abff96 100644
--- a/erpnext/schools/doctype/grading_scale/grading_scale.py
+++ b/erpnext/schools/doctype/grading_scale/grading_scale.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _
+from frappe.utils import cint
 from frappe.model.document import Document
 
 class GradingScale(Document):
@@ -12,8 +13,8 @@
 		thresholds = []
 		for d in self.intervals:
 			if d.threshold in thresholds:
-				frappe.throw(_("Treshold {0}% appears more than once.".format(d.threshold)))
+				frappe.throw(_("Treshold {0}% appears more than once".format(d.threshold)))
 			else:
-				thresholds.append(d.threshold)
+				thresholds.append(cint(d.threshold))
 		if 0 not in thresholds:
 			frappe.throw(_("Please define grade for treshold 0%"))
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student/student.json b/erpnext/schools/doctype/student/student.json
index 50efdc1..9595dfa 100644
--- a/erpnext/schools/doctype/student/student.json
+++ b/erpnext/schools/doctype/student/student.json
@@ -22,7 +22,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "First Name", 
@@ -50,7 +49,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Middle Name", 
@@ -78,7 +76,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Last Name", 
@@ -106,7 +103,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -133,7 +129,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Naming Series", 
@@ -162,7 +157,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Student Email Address", 
@@ -190,7 +184,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Student Mobile Number", 
@@ -220,7 +213,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Joining Date", 
@@ -248,7 +240,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Image", 
@@ -278,7 +269,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Personal Details", 
@@ -306,7 +296,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Date of Birth", 
@@ -334,7 +323,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Blood Group", 
@@ -363,7 +351,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -390,7 +377,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Gender", 
@@ -419,7 +405,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Nationality", 
@@ -448,7 +433,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Student Applicant", 
@@ -477,7 +461,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Guardian Details", 
@@ -505,7 +488,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Guardians", 
@@ -534,7 +516,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Home Address", 
@@ -562,7 +543,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Address Line 1", 
@@ -590,7 +570,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Address Line 2", 
@@ -618,7 +597,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Pincode", 
@@ -646,7 +624,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -673,7 +650,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "City", 
@@ -701,7 +677,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "State", 
@@ -729,7 +704,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Sibling Details", 
@@ -758,7 +732,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Siblings", 
@@ -788,7 +761,6 @@
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Title", 
@@ -819,7 +791,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-01-27 13:19:55.693540", 
+ "modified": "2017-02-03 05:07:48.915706", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student", 
@@ -855,7 +827,7 @@
    "email": 1, 
    "export": 1, 
    "if_owner": 0, 
-   "import": 0, 
+   "import": 1, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
diff --git a/erpnext/schools/doctype/student/student.py b/erpnext/schools/doctype/student/student.py
index a34bb6a..b660bb3 100644
--- a/erpnext/schools/doctype/student/student.py
+++ b/erpnext/schools/doctype/student/student.py
@@ -5,9 +5,9 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.model.document import Document
+from frappe import _
 
 class Student(Document):
-
 	def validate(self):
 		self.title = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name]))
 
@@ -19,7 +19,7 @@
 		"""Validates if the Student Applicant is Unique"""
 		student = frappe.db.sql("select name from `tabStudent` where student_applicant=%s and name!=%s", (self.student_applicant, self.name))
 		if student:
-			frappe.throw("Student {0} exist against student applicant {1}".format(student[0][0], self.student_applicant))
+			frappe.throw(_("Student {0} exist against student applicant {1}").format(student[0][0], self.student_applicant))
 
 	def update_applicant_status(self):
 		"""Updates Student Applicant status to Admitted"""
@@ -28,10 +28,9 @@
 
 def get_timeline_data(doctype, name):
 	'''Return timeline for attendance'''
-	return dict(frappe.db.sql('''select unix_timestamp(cs.schedule_date), count(*)
-		from `tabCourse Schedule` as cs , `tabStudent Attendance` as sa where
-			sa.course_schedule = cs.name
-			and sa.student=%s
-			and cs.schedule_date > date_sub(curdate(), interval 1 year)
+	return dict(frappe.db.sql('''select unix_timestamp(`date`), count(*)
+		from `tabStudent Attendance` where
+			student=%s
+			and `date` > date_sub(curdate(), interval 1 year)
 			and status = 'Present'
-			group by cs.schedule_date''', name))
+			group by date''', name))
diff --git a/erpnext/schools/doctype/student_attendance/student_attendance.py b/erpnext/schools/doctype/student_attendance/student_attendance.py
index e2d01b5..8e806e4 100644
--- a/erpnext/schools/doctype/student_attendance/student_attendance.py
+++ b/erpnext/schools/doctype/student_attendance/student_attendance.py
@@ -6,11 +6,15 @@
 import frappe
 from frappe.model.document import Document
 from frappe import _
+from erpnext.schools.api import get_student_batch_students, get_student_group_students
+
 
 class StudentAttendance(Document):
 	def validate(self):
 		self.validate_date()
 		self.validate_mandatory()
+		self.validate_course_schedule()
+		self.validate_student()
 		self.validate_duplication()
 		
 	def validate_date(self):
@@ -21,9 +25,27 @@
 		if not (self.student_batch or self.course_schedule):
 			frappe.throw(_("""Student Batch or Course Schedule is mandatory"""))
 	
+	def validate_course_schedule(self):
+		if self.course_schedule:
+			self.student_batch = frappe.db.get_value("Course Schedule", self.course_schedule, "student_batch")
+	
+	def validate_student(self):
+		if self.course_schedule:
+			student_group = frappe.db.get_value("Course Schedule", self.course_schedule, "student_group")
+			student_group_students = []
+			for d in get_student_group_students(student_group):
+				student_group_students.append(d.student)
+			if student_group and self.student not in student_group_students:
+				frappe.throw(_("""Student {0}: {1} does not belong to Student Group {2}""".format(self.student, self.student_name, student_group)))
+		else:
+			student_batch_students = []
+			for d in get_student_batch_students(self.student_batch):
+				student_batch_students.append(d.student)
+			if self.student not in student_batch_students:
+				frappe.throw(_("""Student {0}: {1} does not belong to Student Batch {2}""".format(self.student, self.student_name, self.student_batch)))
+
 	def validate_duplication(self):
 		"""Check if the Attendance Record is Unique"""
-		
 		attendance_records=None
 		if self.course_schedule:
 			attendance_records= frappe.db.sql("""select name from `tabStudent Attendance` where \
diff --git a/erpnext/schools/doctype/student_batch/student_batch.json b/erpnext/schools/doctype/student_batch/student_batch.json
index f571d9d..4909ff0 100644
--- a/erpnext/schools/doctype/student_batch/student_batch.json
+++ b/erpnext/schools/doctype/student_batch/student_batch.json
@@ -1,7 +1,7 @@
 {
  "allow_copy": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
+ "allow_import": 1, 
+ "allow_rename": 1, 
  "autoname": "", 
  "beta": 0, 
  "creation": "2016-07-21 15:49:53.776461", 
@@ -22,7 +22,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Student Batch Name", 
@@ -51,7 +50,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 1, 
    "label": "Academic Year", 
@@ -81,7 +79,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Active", 
@@ -109,7 +106,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -136,7 +132,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 1, 
    "label": "Program", 
@@ -165,7 +160,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 1, 
    "label": "Academic Term", 
@@ -194,7 +188,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Students", 
@@ -222,7 +215,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Students", 
@@ -251,7 +243,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Instructors", 
@@ -279,7 +270,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "label": "Instructors", 
@@ -309,7 +299,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-01 13:18:12.024001", 
+ "modified": "2017-02-03 05:19:35.037148", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Batch", 
@@ -325,8 +315,7 @@
    "email": 1, 
    "export": 1, 
    "if_owner": 0, 
-   "import": 0, 
-   "is_custom": 0, 
+   "import": 1, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
@@ -347,7 +336,6 @@
    "export": 0, 
    "if_owner": 0, 
    "import": 0, 
-   "is_custom": 0, 
    "permlevel": 0, 
    "print": 0, 
    "read": 1, 
@@ -365,5 +353,6 @@
  "sort_field": "modified", 
  "sort_order": "DESC", 
  "title_field": "", 
+ "track_changes": 0, 
  "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_batch_student/student_batch_student.json b/erpnext/schools/doctype/student_batch_student/student_batch_student.json
index 558281b..3558cc8 100644
--- a/erpnext/schools/doctype/student_batch_student/student_batch_student.json
+++ b/erpnext/schools/doctype/student_batch_student/student_batch_student.json
@@ -20,7 +20,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Student", 
@@ -49,7 +48,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
    "length": 0, 
@@ -76,13 +74,12 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Student Name", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "", 
+   "options": "student.title", 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
@@ -106,7 +103,6 @@
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
-   "in_filter": 0, 
    "in_list_view": 1, 
    "in_standard_filter": 0, 
    "label": "Active", 
@@ -135,7 +131,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2017-01-27 14:47:21.125366", 
+ "modified": "2017-02-03 05:26:35.518004", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Batch Student", 
diff --git a/erpnext/schools/doctype/student_group/student_group.py b/erpnext/schools/doctype/student_group/student_group.py
index f604773..2f27957 100644
--- a/erpnext/schools/doctype/student_group/student_group.py
+++ b/erpnext/schools/doctype/student_group/student_group.py
@@ -7,6 +7,7 @@
 from frappe.model.document import Document
 from frappe import _
 from erpnext.schools.utils import validate_duplicate_student
+from erpnext.schools.api import get_student_batch_students
 
 class StudentGroup(Document):
 	def autoname(self):
@@ -29,6 +30,8 @@
 	def validate(self):
 		self.validate_strength()
 		self.validate_student_name()
+		if self.student_batch:
+			self.validate_student_batch()
 		validate_duplicate_student(self.students)
 
 	def validate_strength(self):
@@ -39,4 +42,10 @@
 		for d in self.students:
 			d.student_name = frappe.db.get_value("Student", d.student, "title")
 	
-	
\ No newline at end of file
+	def validate_student_batch(self):
+		student_batch_students = []
+		for d in get_student_batch_students(self.student_batch):
+			student_batch_students.append(d.student)
+		for d in self.students:
+			if d.student not in student_batch_students:
+				frappe.throw(_("""Student {0}: {1} does not belong to Student Batch {2}""".format(d.student, d.student_name, self.student_batch)))
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 8a4a47c..f01e484 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -4,11 +4,23 @@
 {% include 'erpnext/selling/sales_common.js' %}
 
 frappe.ui.form.on("Sales Order", {
+	setup: function(frm) {
+		$.extend(frm.cscript, new erpnext.selling.SalesOrderController({frm: frm}));
+	},
 	onload: function(frm) {
 		erpnext.queries.setup_queries(frm, "Warehouse", function() {
 			return erpnext.queries.warehouse(frm.doc);
 		});
 
+		frm.set_query('project', function(doc, cdt, cdn) {
+			return {
+				query: "erpnext.controllers.queries.get_project_name",
+				filters: {
+					'customer': doc.customer
+				}
+			}
+		});
+
 		// formatter for material request item
 		frm.set_indicator_formatter('item_code',
 			function(doc) { return (doc.qty<=doc.delivered_qty) ? "green" : "orange" })
@@ -17,6 +29,7 @@
 
 erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
 	refresh: function(doc, dt, dn) {
+		var me = this;
 		this._super();
 		var allow_purchase = false;
 		var allow_delivery = false;
@@ -24,8 +37,8 @@
 		if(doc.docstatus==1) {
 			if(doc.status != 'Closed') {
 
-				for (var i in cur_frm.doc.items) {
-					var item = cur_frm.doc.items[i];
+				for (var i in this.frm.doc.items) {
+					var item = this.frm.doc.items[i];
 					if(item.delivered_by_supplier === 1 || item.supplier){
 						if(item.qty > flt(item.ordered_qty)
 							&& item.qty > flt(item.delivered_qty)) {
@@ -47,55 +60,69 @@
 				if (this.frm.has_perm("submit")) {
 					// close
 					if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) {
-							cur_frm.add_custom_button(__('Close'), this.close_sales_order, __("Status"))
+							this.frm.add_custom_button(__('Close'),
+								function() { me.close_sales_order() }, __("Status"))
 						}
 				}
 
 				// delivery note
 				if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
-					cur_frm.add_custom_button(__('Delivery'), this.make_delivery_note, __("Make"));
-					cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
+					this.frm.add_custom_button(__('Delivery'),
+						function() { me.make_delivery_note() }, __("Make"));
+					this.frm.add_custom_button(__('Production Order'),
+						function() { me.make_production_order() }, __("Make"));
+
+					this.frm.page.set_inner_btn_group_as_primary(__("Make"));
 				}
 
 				// sales invoice
 				if(flt(doc.per_billed, 2) < 100) {
-					cur_frm.add_custom_button(__('Invoice'), this.make_sales_invoice, __("Make"));
+					this.frm.add_custom_button(__('Invoice'),
+						function() { me.make_sales_invoice() }, __("Make"));
 				}
 
 				// material request
 				if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
 					&& flt(doc.per_delivered, 2) < 100) {
-						cur_frm.add_custom_button(__('Material Request'), this.make_material_request, __("Make"));
+						this.frm.add_custom_button(__('Material Request'),
+							function() { me.make_material_request() }, __("Make"));
 				}
 
 				// make purchase order
 				if(flt(doc.per_delivered, 2) < 100 && allow_purchase) {
-					cur_frm.add_custom_button(__('Purchase Order'), cur_frm.cscript.make_purchase_order, __("Make"));
+					this.frm.add_custom_button(__('Purchase Order'),
+						function() { me.make_purchase_order() }, __("Make"));
 				}
 
+				// payment request
 				if(flt(doc.per_billed)==0) {
-					cur_frm.add_custom_button(__('Payment Request'), this.make_payment_request, __("Make"));
-					cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_payment_entry, __("Make"));
+					this.frm.add_custom_button(__('Payment Request'),
+						function() { me.make_payment_request() }, __("Make"));
+					this.frm.add_custom_button(__('Payment'),
+						function() { me.make_payment_entry() }, __("Make"));
 				}
 
 				// maintenance
 				if(flt(doc.per_delivered, 2) < 100 &&
 						["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
-					cur_frm.add_custom_button(__('Maintenance Visit'), this.make_maintenance_visit, __("Make"));
-					cur_frm.add_custom_button(__('Maintenance Schedule'), this.make_maintenance_schedule, __("Make"));
+					this.frm.add_custom_button(__('Maintenance Visit'),
+						function() { me.make_maintenance_visit() }, __("Make"));
+					this.frm.add_custom_button(__('Maintenance Schedule'),
+						function() { me.make_maintenance_schedule() }, __("Make"));
 				}
 
-
 			} else {
 				if (this.frm.has_perm("submit")) {
 					// un-close
-					cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unclose Sales Order'], __("Status"));
+					this.frm.add_custom_button(__('Re-open'), function() {
+						me.frm.cscript.update_status('Re-open', 'Draft')
+					}, __("Status"));
 				}
 			}
 		}
 
 		if (this.frm.doc.docstatus===0) {
-			cur_frm.add_custom_button(__('Quotation'),
+			this.frm.add_custom_button(__('Quotation'),
 				function() {
 					erpnext.utils.map_current_doc({
 						method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
@@ -103,9 +130,9 @@
 						get_query_filters: {
 							docstatus: 1,
 							status: ["!=", "Lost"],
-							order_type: cur_frm.doc.order_type,
-							customer: cur_frm.doc.customer || undefined,
-							company: cur_frm.doc.company
+							order_type: me.frm.doc.order_type,
+							customer: me.frm.doc.customer || undefined,
+							company: me.frm.doc.company
 						}
 					})
 				}, __("Get items from"));
@@ -114,6 +141,82 @@
 		this.order_type(doc);
 	},
 
+	make_production_order() {
+		var me = this;
+		this.frm.call({
+			doc: this.frm.doc,
+			method: 'get_production_order_items',
+			callback: function(r) {
+				if(!r.message.every(function(d) { return !!d.bom })) {
+					frappe.msgprint({
+						title: __('Production Order not created'),
+						message: __('No Items with Bill of Materials to Manufacture'),
+						indicator: 'orange'
+					});
+					return;
+				}
+				else if(!r.message.every(function(d) { return !!d.pending_qty })) {
+					frappe.msgprint({
+						title: __('Production Order not created'),
+						message: __('Production Order already created for all items with BOM'),
+						indicator: 'orange'
+					});
+					return;
+				} else {
+					var fields = [
+						{fieldtype:'Table', fieldname: 'items',
+							description: __('Select BOM and Qty for Production'),
+							fields: [
+								{fieldtype:'Read Only', fieldname:'item_code',
+									label: __('Item Code'), in_list_view:1},
+								{fieldtype:'Link', fieldname:'bom', options: 'BOM',
+									label: __('Select BOM'), in_list_view:1, get_query: function(doc) {
+										return {filters: {item: doc.item_code}};
+									}},
+								{fieldtype:'Float', fieldname:'pending_qty',
+									label: __('Qty'), in_list_view:1},
+							],
+							get_data: function() {
+								return r.message
+							}
+						}
+					]
+					var d = new frappe.ui.Dialog({
+						title: __('Select Items to Manufacture'),
+						fields: fields,
+						primary_action: function() {
+							data = d.get_values();
+							me.frm.call({
+								method: 'make_production_orders',
+								args: {
+									items: data,
+									company: me.frm.doc.company,
+									sales_order: me.frm.docname,
+									project: me.frm.project
+								},
+								freeze: true,
+								callback: function(r) {
+									if(r.message) {
+										frappe.msgprint({
+											message: __('Production Orders Created: {0}',
+												[r.message.map(function(d) {
+													return repl('<a href="#Form/Production Order/%(name)s">%(name)s</a>', {name:d})
+												}).join(', ')]),
+											indicator: 'green'
+										})
+									}
+									d.hide();
+								}
+							});
+						},
+						primary_action_label: __('Make')
+					});
+					d.show();
+				}
+			}
+		});
+	},
+
 	order_type: function() {
 		this.frm.toggle_reqd("delivery_date", this.frm.doc.order_type == "Sales");
 	},
@@ -125,39 +228,40 @@
 	make_material_request: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request",
-			frm: cur_frm
+			frm: this.frm
 		})
 	},
 
 	make_delivery_note: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
-			frm: cur_frm
+			frm: this.frm
 		})
 	},
 
 	make_sales_invoice: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
-			frm: cur_frm
+			frm: this.frm
 		})
 	},
 
 	make_maintenance_schedule: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_schedule",
-			frm: cur_frm
+			frm: this.frm
 		})
 	},
 
 	make_maintenance_visit: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
-			frm: cur_frm
+			frm: this.frm
 		})
 	},
 
 	make_purchase_order: function(){
+		var me = this;
 		var dialog = new frappe.ui.Dialog({
 			title: __("For Supplier"),
 			fields: [
@@ -165,7 +269,7 @@
 					"get_query": function () {
 						return {
 							query:"erpnext.selling.doctype.sales_order.sales_order.get_supplier",
-							filters: {'parent': cur_frm.doc.name}
+							filters: {'parent': me.frm.doc.name}
 						}
 					}, "reqd": 1 },
 				{"fieldtype": "Button", "label": __("Make Purchase Order"), "fieldname": "make_purchase_order", "cssClass": "btn-primary"},
@@ -180,7 +284,7 @@
 				type: "GET",
 				method: "erpnext.selling.doctype.sales_order.sales_order.make_purchase_order_for_drop_shipment",
 				args: {
-					"source_name": cur_frm.doc.name,
+					"source_name": me.frm.doc.name,
 					"for_supplier": args.supplier
 				},
 				freeze: true,
@@ -195,44 +299,25 @@
 		dialog.show();
 	},
 	close_sales_order: function(){
-		cur_frm.cscript.update_status("Close", "Closed")
+		this.frm.cscript.update_status("Close", "Closed")
+	},
+	update_status: function(label, status){
+		var doc = this.frm.doc;
+		frappe.ui.form.is_saving = true;
+		frappe.call({
+			method: "erpnext.selling.doctype.sales_order.sales_order.update_status",
+			args: {status: status, name: doc.name},
+			callback: function(r){
+				this.frm.reload_doc();
+			},
+			always: function() {
+				frappe.ui.form.is_saving = false;
+			}
+		});
+	},
+	on_submit: function(doc, cdt, cdn) {
+		if(cint(frappe.boot.notification_settings.sales_order)) {
+			this.frm.email_doc(frappe.boot.notification_settings.sales_order_message);
+		}
 	}
-
 });
-
-// for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
-
-cur_frm.fields_dict['project'].get_query = function(doc, cdt, cdn) {
-	return {
-		query: "erpnext.controllers.queries.get_project_name",
-		filters: {
-			'customer': doc.customer
-		}
-	}
-}
-
-cur_frm.cscript.update_status = function(label, status){
-	var doc = cur_frm.doc;
-	frappe.ui.form.is_saving = true;
-	frappe.call({
-		method: "erpnext.selling.doctype.sales_order.sales_order.update_status",
-		args: {status: status, name: doc.name},
-		callback: function(r){
-			cur_frm.reload_doc();
-		},
-		always: function() {
-			frappe.ui.form.is_saving = false;
-		}
-	});
-}
-
-cur_frm.cscript['Unclose Sales Order'] = function() {
-	cur_frm.cscript.update_status('Re-open', 'Draft')
-}
-
-cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
-	if(cint(frappe.boot.notification_settings.sales_order)) {
-		cur_frm.email_doc(frappe.boot.notification_settings.sales_order_message);
-	}
-};
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index acae0e5..fdaadd8 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -304,6 +304,24 @@
 			self.indicator_color = "green"
 			self.indicator_title = _("Paid")
 
+	def get_production_order_items(self):
+		'''Returns items with BOM that already do not have a linked production order'''
+		items = []
+		for i in self.packed_items or self.items:
+			bom = frappe.get_all('BOM', dict(item=i.item_code, is_active=True),
+					order_by='is_default desc')
+			bom = bom[0].name if bom else None
+			items.append(dict(
+				item_code= i.item_code,
+				bom = bom,
+				warehouse = i.warehouse,
+				pending_qty= i.qty - flt(frappe.db.sql('''select sum(qty) from `tabProduction Order`
+					where production_item=%s and sales_order=%s''', (i.item_code, self.name))[0][0])
+			))
+
+		return items
+
+
 	def on_recurring(self, reference_doc):
 		mcount = month_map[reference_doc.recurring_type]
 		self.set("delivery_date", get_next_date(reference_doc.delivery_date, mcount,
@@ -442,7 +460,7 @@
 		target.amount = flt(source.amount) - flt(source.billed_amt)
 		target.base_amount = target.amount * flt(source_parent.conversion_rate)
 		target.qty = target.amount / flt(source.rate) if (source.rate and source.billed_amt) else source.qty
-		
+
 		item = frappe.db.get_value("Item", target.item_code, ["item_group", "selling_cost_center"], as_dict=1)
 		target.cost_center = frappe.db.get_value("Project", source_parent.project, "cost_center") \
 			or item.selling_cost_center \
@@ -653,6 +671,27 @@
 		})
 
 @frappe.whitelist()
+def make_production_orders(items, sales_order, company, project=None):
+	'''Make Production Orders against the given Sales Order for the given `items`'''
+	items = json.loads(items).get('items')
+	out = []
+
+	for i in items:
+		production_order = frappe.get_doc(dict(
+			doctype='Production Order',
+			production_item=i['item_code'],
+			bom_no=i['bom'],
+			qty=i['pending_qty'],
+			company=company,
+			sales_order=sales_order,
+			project=project,
+			fg_warehouse=i['warehouse']
+		)).insert()
+		out.append(production_order)
+
+	return [p.name for p in out]
+
+@frappe.whitelist()
 def update_status(status, name):
 	so = frappe.get_doc("Sales Order", name)
 	so.update_status(status)
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index e1ac06e..1147d8d 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
@@ -1477,6 +1477,34 @@
    "width": "120px"
   }, 
   {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "is_sample_item", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Sample Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1691,7 +1719,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-12-24 12:33:37.728117", 
+ "modified": "2017-02-07 01:22:03.047137", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Delivery Note Item", 
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index d8449f1..5903713 100755
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -1575,6 +1575,34 @@
    "unique": 0
   }, 
   {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "is_sample_item", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Sample Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -1885,7 +1913,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-11-16 16:04:21.778869", 
+ "modified": "2017-02-07 01:21:36.348032", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Purchase Receipt Item", 
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index b410802..37f9b68 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -41,6 +41,10 @@
 				}
 			}
 		}
+
+		this.frm.set_indicator_formatter('item_code',
+			function(doc) { return (doc.qty<=doc.actual_qty) ? "green" : "orange" })
+
 	},
 
 	onload_post_render: function() {
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index ed1843e..34b3c85 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -10,6 +10,7 @@
  "doctype": "DocType", 
  "document_type": "Other", 
  "editable_grid": 1, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -23,6 +24,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Barcode", 
    "length": 0, 
    "no_copy": 0, 
@@ -50,6 +52,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -76,6 +79,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Source Warehouse", 
    "length": 0, 
    "no_copy": 0, 
@@ -105,6 +109,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -130,6 +135,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Target Warehouse", 
    "length": 0, 
    "no_copy": 0, 
@@ -159,6 +165,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -184,6 +191,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Item Code", 
    "length": 0, 
    "no_copy": 0, 
@@ -213,6 +221,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -238,6 +247,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Item Name", 
    "length": 0, 
    "no_copy": 0, 
@@ -264,6 +274,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -291,6 +302,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -321,6 +333,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -347,6 +360,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Image", 
    "length": 0, 
    "no_copy": 0, 
@@ -374,6 +388,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Image View", 
    "length": 0, 
    "no_copy": 0, 
@@ -402,6 +417,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Quantity and Rate", 
    "length": 0, 
    "no_copy": 0, 
@@ -420,7 +436,7 @@
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
-   "columns": 1, 
+   "columns": 3, 
    "fieldname": "qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -428,6 +444,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Qty", 
    "length": 0, 
    "no_copy": 0, 
@@ -448,14 +465,15 @@
    "allow_on_submit": 0, 
    "bold": 1, 
    "collapsible": 0, 
-   "columns": 2, 
+   "columns": 0, 
    "fieldname": "basic_rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 1, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Basic Rate (as per Stock UOM)", 
    "length": 0, 
    "no_copy": 0, 
@@ -485,6 +503,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Basic Amount", 
    "length": 0, 
    "no_copy": 0, 
@@ -513,6 +532,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Additional Cost", 
    "length": 0, 
    "no_copy": 0, 
@@ -541,6 +561,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Amount", 
    "length": 0, 
    "no_copy": 0, 
@@ -570,6 +591,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Valuation Rate", 
    "length": 0, 
    "no_copy": 0, 
@@ -598,6 +620,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -623,6 +646,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "UOM", 
    "length": 0, 
    "no_copy": 0, 
@@ -652,6 +676,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Conversion Factor", 
    "length": 0, 
    "no_copy": 0, 
@@ -680,6 +705,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Stock UOM", 
    "length": 0, 
    "no_copy": 0, 
@@ -709,6 +735,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Qty as per Stock UOM", 
    "length": 0, 
    "no_copy": 0, 
@@ -737,6 +764,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Serial No / Batch", 
    "length": 0, 
    "no_copy": 0, 
@@ -763,6 +791,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Serial No", 
    "length": 0, 
    "no_copy": 1, 
@@ -791,6 +820,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -816,6 +846,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Batch No", 
    "length": 0, 
    "no_copy": 0, 
@@ -845,6 +876,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Accounting", 
    "length": 0, 
    "no_copy": 0, 
@@ -872,6 +904,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Difference Account", 
    "length": 0, 
    "no_copy": 0, 
@@ -899,6 +932,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -926,6 +960,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Cost Center", 
    "length": 0, 
    "no_copy": 0, 
@@ -953,6 +988,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "More Information", 
    "length": 0, 
    "no_copy": 0, 
@@ -972,6 +1008,34 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "is_sample_item", 
+   "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Is Sample Item", 
+   "length": 0, 
+   "no_copy": 1, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 1, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "actual_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
@@ -979,6 +1043,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Actual Qty (at source/target)", 
    "length": 0, 
    "no_copy": 1, 
@@ -1008,6 +1073,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "BOM No", 
    "length": 0, 
    "no_copy": 0, 
@@ -1035,6 +1101,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -1061,6 +1128,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Material Request", 
    "length": 0, 
    "no_copy": 1, 
@@ -1088,6 +1156,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Material Request Item", 
    "length": 0, 
    "no_copy": 1, 
@@ -1114,7 +1183,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-11-27 15:19:26.597414", 
+ "modified": "2017-02-07 01:21:14.367586", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Stock Entry Detail", 
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 0f1e30d..b9b11a8 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -73,7 +73,7 @@
 
 	out.update(get_pricing_rule_for_item(args))
 
-	if args.get("doctype") in ("Sales Invoice", "Delivery Note"):
+	if args.get("doctype") in ("Sales Invoice", "Delivery Note") and out.qty > 0:
 		out.serial_no = get_serial_no(out)
 
 	if args.transaction_date and item.lead_time_days:
@@ -387,7 +387,8 @@
 def get_bin_details_and_serial_nos(item_code, warehouse, qty=None, serial_no=None):
 	bin_details_and_serial_nos = {}
 	bin_details_and_serial_nos.update(get_bin_details(item_code, warehouse))
-	bin_details_and_serial_nos.update(get_serial_no_details(item_code, warehouse, qty, serial_no))
+	if qty > 0:
+		bin_details_and_serial_nos.update(get_serial_no_details(item_code, warehouse, qty, serial_no))
 	return bin_details_and_serial_nos
 
 @frappe.whitelist()
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index a4cc512..10722cc 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -258,11 +258,14 @@
 
 			if not self.valuation_rate and actual_qty > 0:
 				self.valuation_rate = sle.incoming_rate
+				
+			# Get valuation rate from previous SLE or Item master, if item is not a sample item
+			if not self.valuation_rate and sle.voucher_detail_no:
+				is_sample_item = self.check_if_sample_item(sle.voucher_type, sle.voucher_detail_no)
+				if not is_sample_item:
+					self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse, 
+						sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
 		
-		if not self.valuation_rate:
-			self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse, 
-				sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
-
 	def get_fifo_values(self, sle):
 		incoming_rate = flt(sle.incoming_rate)
 		actual_qty = flt(sle.actual_qty)
@@ -286,8 +289,13 @@
 			while qty_to_pop:
 				if not self.stock_queue:
 					# Get valuation rate from last sle if exists or from valuation rate field in item master
-					_rate = get_valuation_rate(sle.item_code, sle.warehouse, 
-				sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
+					is_sample_item = self.check_if_sample_item(sle.voucher_type, sle.voucher_detail_no)
+					if not is_sample_item:
+						_rate = get_valuation_rate(sle.item_code, sle.warehouse, 
+							sle.voucher_type, sle.voucher_no, self.allow_zero_rate)
+					else:
+						_rate = 0
+						
 					self.stock_queue.append([0, _rate])
 
 				index = None
@@ -333,7 +341,11 @@
 
 		if not self.stock_queue:
 			self.stock_queue.append([0, sle.incoming_rate or sle.outgoing_rate or self.valuation_rate])
-
+			
+	def check_if_sample_item(self, voucher_type, voucher_detail_no):
+		ref_item_dt = voucher_type + (" Detail" if voucher_type == "Stock Entry" else " Item")
+		return frappe.db.get_value(ref_item_dt, voucher_detail_no, "is_sample_item")
+		
 	def get_sle_before_datetime(self):
 		"""get previous stock ledger entry before current time-bucket"""
 		return get_stock_ledger_entries(self.args, "<", "desc", "limit 1", for_update=False)
@@ -432,7 +444,6 @@
 	if not allow_zero_rate and not valuation_rate \
 			and cint(frappe.db.get_value("Accounts Settings", None, "auto_accounting_for_stock")):
 			
-		frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting {1} {2}")
-		.format(item_code, voucher_type, voucher_no))
+		frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a sample item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
 
 	return valuation_rate
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index f2d8bd5..e5c6ee1 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -81,9 +81,15 @@
 	st.save()
 
 def auto_close_tickets():
-	frappe.db.sql("""update `tabIssue` set status = 'Closed'
-		where status = 'Replied'
-		and date_sub(curdate(),interval 15 Day) > modified""")
+	issues = frappe.db.get_all("Issue", filters={
+		"status": "Replied",
+		"modified": ("<", "date_sub(curdate(),interval 7 Day)")
+	}, fields=["name"])
+
+	for issue in issues:
+		doc = frappe.get_doc("Issue", issue.get("name"))
+		doc.status = "Closed"
+		doc.save(ignore_permissions=True)
 
 @frappe.whitelist()
 def set_multiple_status(names, status):