Merge pull request #7446 from KanchanChauhan/fieldtype-edit-desc

[Minor] Field type of Description field changed to Text Editor
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index c6a8ea1..bc7ef57 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.2.6'
+__version__ = '7.2.8'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index 5fc4fbf..15d6f10 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -63,7 +63,7 @@
 				and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}):
 
 			if args.project:
-				condition = "and exists(select name from `tabProject` where name=b.project)"
+				condition = "and b.project='%s'" % frappe.db.escape(args.project)
 				args.budget_against_field = "Project"
 			
 			elif args.cost_center:
@@ -88,12 +88,13 @@
 			""".format(condition=condition, 
 				budget_against_field=frappe.scrub(args.get("budget_against_field"))),
 				(args.fiscal_year, args.account), as_dict=True)
-
-			validate_budget_records(args, budget_records)
+				
+			if budget_records:
+				validate_budget_records(args, budget_records)
 
 def validate_budget_records(args, budget_records):
 	for budget in budget_records:
-		if budget.budget_amount:
+		if flt(budget.budget_amount):
 			yearly_action = budget.action_if_annual_budget_exceeded
 			monthly_action = budget.action_if_accumulated_monthly_budget_exceeded
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index db6d594..c5aa7ea 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -651,32 +651,34 @@
 	def make_pos_gl_entries(self, gl_entries):
 		if cint(self.is_pos):
 			for payment_mode in self.payments:
-				# POS, make payment entries
-				gl_entries.append(
-					self.get_gl_dict({
-						"account": self.debit_to,
-						"party_type": "Customer",
-						"party": self.customer,
-						"against": payment_mode.account,
-						"credit": payment_mode.base_amount,
-						"credit_in_account_currency": payment_mode.base_amount \
-							if self.party_account_currency==self.company_currency \
-							else payment_mode.amount,
-						"against_voucher": self.return_against if cint(self.is_return) else self.name,
-						"against_voucher_type": self.doctype,
-					}, self.party_account_currency)
-				)
+				if payment_mode.amount:
+					# POS, make payment entries
+					gl_entries.append(
+						self.get_gl_dict({
+							"account": self.debit_to,
+							"party_type": "Customer",
+							"party": self.customer,
+							"against": payment_mode.account,
+							"credit": payment_mode.base_amount,
+							"credit_in_account_currency": payment_mode.base_amount \
+								if self.party_account_currency==self.company_currency \
+								else payment_mode.amount,
+							"against_voucher": self.return_against if cint(self.is_return) else self.name,
+							"against_voucher_type": self.doctype,
+						}, self.party_account_currency)
+					)
 
-				payment_mode_account_currency = get_account_currency(payment_mode.account)
-				gl_entries.append(
-					self.get_gl_dict({
-						"account": payment_mode.account,
-						"against": self.customer,
-						"debit": payment_mode.base_amount,
-						"debit_in_account_currency": payment_mode.base_amount \
-							if payment_mode_account_currency==self.company_currency else payment_mode.amount
-					}, payment_mode_account_currency)
-				)
+					payment_mode_account_currency = get_account_currency(payment_mode.account)
+					gl_entries.append(
+						self.get_gl_dict({
+							"account": payment_mode.account,
+							"against": self.customer,
+							"debit": payment_mode.base_amount,
+							"debit_in_account_currency": payment_mode.base_amount \
+								if payment_mode_account_currency==self.company_currency \
+								else payment_mode.amount
+						}, payment_mode_account_currency)
+					)
 				
 	def make_gle_for_change_amount(self, gl_entries):
 		if cint(self.is_pos) and self.change_amount:
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index c092695..d7dce92 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -2212,7 +2212,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -2360,7 +2360,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "% Billed", 
    "length": 0, 
    "no_copy": 1, 
@@ -3062,7 +3062,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-07 06:01:00.233621", 
+ "modified": "2017-01-06 12:51:56.556331", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Purchase Order", 
diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py
index f627b4a..44e247e 100644
--- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py
+++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.py
@@ -3,6 +3,7 @@
 
 from __future__ import unicode_literals
 from erpnext.setup.utils import get_exchange_rate
+from frappe.utils import flt, cint
 import frappe
 
 def execute(filters=None):
@@ -20,6 +21,7 @@
 		price_data = []
 		suppliers = []
 		company_currency = frappe.db.get_default("currency")
+		float_precision = cint(frappe.db.get_default("float_precision")) or 2 
 		# Get the list of suppliers
 		for root in frappe.db.sql("""select parent, qty, rate from `tabSupplier Quotation Item` where item_code=%s and docstatus < 2""", item, as_dict=1):
 			for splr in frappe.db.sql("""SELECT supplier from `tabSupplier Quotation` where name =%s and docstatus < 2""", root.parent, as_dict=1):
@@ -46,7 +48,7 @@
 				# Get the quantity for this row
 				for item_price in price_data:
 					if str(item_price.qty) == col.key and item_price.supplier == root:
-						row[col.key] = item_price.rate * exchange_rate
+						row[col.key] = flt(item_price.rate * exchange_rate, float_precision)
 						row[col.key + "QUOTE"] = item_price.parent
 						break
 					else:
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js
index 0ad8cec..cfb646d 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.js
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.js
@@ -7,6 +7,7 @@
 		frm.doc.start_date = '';
 		frm.doc.end_date = '';
 		frm.doc.payroll_frequency = '';
+		frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
 	},
 
 	refresh: function(frm) {
@@ -25,6 +26,10 @@
 		frm.trigger("set_start_end_dates");
 	},
 
+	salary_slip_based_on_timesheet: function(frm) {
+		frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
+	},
+
 	payment_account: function(frm) {
 		frm.toggle_display(['make_bank_entry'], (frm.doc.payment_account!="" && frm.doc.payment_account!="undefined"));
 	},
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py
index 45030cb..7741263 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.py
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.py
@@ -68,7 +68,7 @@
 
 
 	def check_mandatory(self):
-		for fieldname in ['company', 'payroll_frequency', 'start_date', 'end_date']:
+		for fieldname in ['company', 'start_date', 'end_date']:
 			if not self.get(fieldname):
 				frappe.throw(_("Please set {0}").format(self.meta.get_label(fieldname)))
 
diff --git a/erpnext/patches/v5_0/portal_fixes.py b/erpnext/patches/v5_0/portal_fixes.py
index d7e3b44..260222e 100644
--- a/erpnext/patches/v5_0/portal_fixes.py
+++ b/erpnext/patches/v5_0/portal_fixes.py
@@ -2,5 +2,5 @@
 import erpnext.setup.install
 
 def execute():
-	frappe.reload_doc("website", "doctype", "web_form_field", force=True)
+	frappe.reload_doc("website", "doctype", "web_form_field", force=True, reset_permissions=True)
 	#erpnext.setup.install.add_web_forms()
diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json
index 37ca968..38ebbcb 100644
--- a/erpnext/projects/doctype/project/project.json
+++ b/erpnext/projects/doctype/project/project.json
@@ -10,6 +10,7 @@
  "doctype": "DocType", 
  "document_type": "Setup", 
  "editable_grid": 0, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -24,7 +25,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Project Name", 
    "length": 0, 
    "no_copy": 0, 
@@ -53,7 +53,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
    "label": "Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -83,7 +82,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
    "label": "Project Type", 
    "length": 0, 
    "no_copy": 0, 
@@ -113,7 +111,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
    "label": "Is Active", 
    "length": 0, 
    "no_copy": 0, 
@@ -144,7 +141,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "% Complete Method", 
    "length": 0, 
    "no_copy": 0, 
@@ -173,7 +169,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -200,7 +195,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
    "label": "Priority", 
    "length": 0, 
    "no_copy": 0, 
@@ -230,7 +224,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Expected Start Date", 
    "length": 0, 
    "no_copy": 0, 
@@ -259,7 +252,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Expected End Date", 
    "length": 0, 
    "no_copy": 0, 
@@ -288,7 +280,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "% Completed", 
    "length": 0, 
    "no_copy": 1, 
@@ -315,7 +306,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Customer Details", 
    "length": 0, 
    "no_copy": 0, 
@@ -344,7 +334,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Customer", 
    "length": 0, 
    "no_copy": 0, 
@@ -374,7 +363,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -401,7 +389,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Sales Order", 
    "length": 0, 
    "no_copy": 0, 
@@ -430,7 +417,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Users", 
    "length": 0, 
    "no_copy": 0, 
@@ -459,7 +445,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Users", 
    "length": 0, 
    "no_copy": 0, 
@@ -488,7 +473,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Tasks", 
    "length": 0, 
    "no_copy": 0, 
@@ -517,7 +501,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Tasks", 
    "length": 0, 
    "no_copy": 0, 
@@ -546,7 +529,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Notes", 
    "length": 0, 
    "no_copy": 0, 
@@ -575,7 +557,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Notes", 
    "length": 0, 
    "no_copy": 0, 
@@ -604,7 +585,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Start and End Dates", 
    "length": 0, 
    "no_copy": 0, 
@@ -632,7 +612,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Actual Start Date", 
    "length": 0, 
    "no_copy": 0, 
@@ -660,7 +639,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Actual Time (in Hours)", 
    "length": 0, 
    "no_copy": 0, 
@@ -688,7 +666,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -715,7 +692,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Actual End Date", 
    "length": 0, 
    "no_copy": 0, 
@@ -744,7 +720,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Costing and Billing", 
    "length": 0, 
    "no_copy": 0, 
@@ -773,7 +748,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
-   "in_standard_filter": 0, 
    "label": "Estimated Cost", 
    "length": 0, 
    "no_copy": 0, 
@@ -804,7 +778,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Total Costing Amount (via Time Logs)", 
    "length": 0, 
    "no_copy": 0, 
@@ -833,7 +806,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Total Expense Claim (via Expense Claims)", 
    "length": 0, 
    "no_copy": 0, 
@@ -861,7 +833,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Company", 
    "length": 0, 
    "no_copy": 0, 
@@ -889,7 +860,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Cost Center", 
    "length": 0, 
    "no_copy": 0, 
@@ -917,7 +887,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -945,7 +914,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Total Billing Amount (via Time Logs)", 
    "length": 0, 
    "no_copy": 0, 
@@ -973,7 +941,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Total Purchase Cost (via Purchase Invoice)", 
    "length": 0, 
    "no_copy": 0, 
@@ -1001,7 +968,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Margin", 
    "length": 0, 
    "no_copy": 0, 
@@ -1030,7 +996,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Gross Margin", 
    "length": 0, 
    "no_copy": 0, 
@@ -1060,7 +1025,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -1087,7 +1051,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Gross Margin %", 
    "length": 0, 
    "no_copy": 0, 
@@ -1117,7 +1080,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 4, 
- "modified": "2016-11-07 05:55:56.179455", 
+ "modified": "2017-01-10 16:33:54.691885", 
  "modified_by": "Administrator", 
  "module": "Projects", 
  "name": "Project", 
@@ -1164,6 +1127,27 @@
    "share": 0, 
    "submit": 0, 
    "write": 0
+  }, 
+  {
+   "amend": 0, 
+   "apply_user_permissions": 0, 
+   "cancel": 0, 
+   "create": 1, 
+   "delete": 1, 
+   "email": 1, 
+   "export": 1, 
+   "if_owner": 0, 
+   "import": 0, 
+   "is_custom": 0, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Projects Manager", 
+   "set_user_permissions": 0, 
+   "share": 1, 
+   "submit": 0, 
+   "write": 1
   }
  ], 
  "quick_entry": 1, 
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 0ae2f8b..2bdcaf9 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -55,7 +55,8 @@
 	def update_depends_on(self):
 		depends_on_tasks = ""
 		for d in self.depends_on:
-			depends_on_tasks += d.task + ","
+			if d.task:
+				depends_on_tasks += d.task + ","
 		self.depends_on_tasks = depends_on_tasks
 
 	def on_update(self):
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index c3dbcd4..490a707 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -199,13 +199,22 @@
 				(%(to_time)s > tsd.from_time and %(to_time)s < tsd.to_time) or
 				(%(from_time)s <= tsd.from_time and %(to_time)s >= tsd.to_time))
 			and tsd.name!=%(name)s
+			and ts.name!=%(parent)s
 			and ts.docstatus < 2""".format(cond),
 			{
 				"val": value,
 				"from_time": args.from_time,
 				"to_time": args.to_time,
-				"name": args.name or "No Name"
+				"name": args.name or "No Name",
+				"parent": args.parent or "No Name"
 			}, as_dict=True)
+		# check internal overlap
+		for time_log in self.time_logs:
+			if (fieldname != 'workstation' or args.get(fieldname) == time_log.get(fieldname)) and \
+				args.idx != time_log.idx and ((args.from_time > time_log.from_time and args.from_time < time_log.to_time) or 
+				(args.to_time > time_log.from_time and args.to_time < time_log.to_time) or 
+				(args.from_time <= time_log.from_time and args.to_time >= time_log.to_time)):
+				return self
 
 		return existing[0] if existing else None
 
@@ -359,7 +368,8 @@
 	conditions = get_conditions(filters)
 	return frappe.db.sql("""select `tabTimesheet Detail`.name as name, 
 			`tabTimesheet Detail`.docstatus as status, `tabTimesheet Detail`.parent as parent,
-			from_time as start_date, hours, activity_type, project, to_time as end_date
+			from_time as start_date, hours, activity_type, project, to_time as end_date, 
+			CONCAT(`tabTimesheet Detail`.parent, ' (', ROUND(hours,2),' hrs)') as title 
 		from `tabTimesheet Detail`, `tabTimesheet` 
 		where `tabTimesheet Detail`.parent = `tabTimesheet`.name 
 			and `tabTimesheet`.docstatus < 2 
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 04f5f95..74e9fb6 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -153,22 +153,37 @@
 			frappe.get_meta(items_doctype).fields.forEach(function(d) { 
 				if(d.options===opts.source_doctype) link_fieldname = d.fieldname; });
 
-			// search in existing items if the source_name is already set
+			// search in existing items if the source_name is already set and full qty fetched
 			var already_set = false;
-
+			var item_qty_map = {};
+			
 			$.each(cur_frm.doc.items, function(i, d) {
 				if(d[link_fieldname]==opts.source_name) {
 					already_set = true;
-					return false;
+					if (item_qty_map[d.item_code])
+						item_qty_map[d.item_code] += flt(d.qty);
+					else
+						item_qty_map[d.item_code] = flt(d.qty);
 				}
 			});
-
+			
 			if(already_set) {
-				frappe.msgprint(__("You have already selected items from {0} {1}", 
-					[opts.source_doctype, opts.source_name]));
-				return;
-			}
+				frappe.model.with_doc(opts.source_doctype, opts.source_name, function(r) {
+					var source_doc = frappe.model.get_doc(opts.source_doctype, opts.source_name);
+					$.each(source_doc.items || [], function(i, row) {
+						if(row.qty > flt(item_qty_map[row.item_code])) {
+							already_set = false;
+							return false;
+						}
+					})
+				})
 
+				if(already_set) {
+					frappe.msgprint(__("You have already selected items from {0} {1}", 
+						[opts.source_doctype, opts.source_name]));
+					return;
+				}
+			}
 		}
 
 
diff --git a/erpnext/schools/doctype/academic_term/academic_term.py b/erpnext/schools/doctype/academic_term/academic_term.py
index 4a1a941..3aa0be15 100644
--- a/erpnext/schools/doctype/academic_term/academic_term.py
+++ b/erpnext/schools/doctype/academic_term/academic_term.py
@@ -5,7 +5,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _
-from frappe.utils import get_datetime
+from frappe.utils import getdate
 from frappe.model.document import Document
 
 class AcademicTerm(Document):
@@ -18,16 +18,18 @@
         self.title = self.academic_year + " ({})".format(self.term_name) if self.term_name else ""
 
         #Check that start of academic year is earlier than end of academic year
-        if self.term_start_date and self.term_end_date and self.term_start_date > self.term_end_date:
+        if self.term_start_date and self.term_end_date \
+				and getdate(self.term_start_date) > getdate(self.term_end_date):
             frappe.throw(_("The Term End Date cannot be earlier than the Term Start Date. Please correct the dates and try again."))
 
-        """Check that the start of the term is not before the start of the academic year and end of term is not after
-            the end of the academic year"""
+        # Check that the start of the term is not before the start of the academic year 
+		# and end of term is not after the end of the academic year"""
+			
         year = frappe.get_doc("Academic Year",self.academic_year)
-        if self.term_start_date and get_datetime(year.year_start_date) and (self.term_start_date < get_datetime(year.year_start_date)):
+        if self.term_start_date and getdate(year.year_start_date) and (getdate(self.term_start_date) < getdate(year.year_start_date)):
             frappe.throw(_("The Term Start Date cannot be earlier than the Year Start Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
 
-        if self.term_end_date and get_datetime(year.year_end_date) and (self.term_end_date > get_datetime(year.year_end_date)):
+        if self.term_end_date and getdate(year.year_end_date) and (getdate(self.term_end_date) > getdate(year.year_end_date)):
             frappe.throw(_("The Term End Date cannot be later than the Year End Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
 
 
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index f171007..51e68fb 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -2580,7 +2580,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Delivery Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -2610,7 +2610,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "%  Delivered", 
    "length": 0, 
    "no_copy": 1, 
@@ -2668,7 +2668,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
-   "in_standard_filter": 1, 
+   "in_standard_filter": 0, 
    "label": "% Amount Billed", 
    "length": 0, 
    "no_copy": 1, 
@@ -2698,7 +2698,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Billing Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -3369,7 +3369,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-16 04:06:28.675876", 
+ "modified": "2017-01-06 12:51:17.847227", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Sales Order", 
@@ -3383,7 +3383,7 @@
    "delete": 1, 
    "email": 1, 
    "export": 0, 
-   "if_owner": 1, 
+   "if_owner": 0, 
    "import": 0, 
    "is_custom": 0, 
    "permlevel": 0, 
diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
index 37f114b..85cf4dd 100644
--- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
+++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
@@ -18,4 +18,6 @@
 		doc = json.loads(doc)
 
 	terms_and_conditions = frappe.get_doc("Terms and Conditions", template_name)
-	return frappe.render_template(terms_and_conditions.terms, doc)
\ No newline at end of file
+	
+	if terms_and_conditions.terms:
+		return frappe.render_template(terms_and_conditions.terms, doc)
\ No newline at end of file
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 8272977..6be4ad8 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -2705,7 +2705,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Status", 
    "length": 0, 
    "no_copy": 1, 
@@ -3120,7 +3120,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2016-12-16 03:56:08.745185", 
+ "modified": "2017-01-06 12:52:48.960308", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Delivery Note", 
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index a31aed4..d902351 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -26,7 +26,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "", 
    "length": 0, 
    "no_copy": 0, 
@@ -55,7 +54,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Series", 
    "length": 0, 
    "no_copy": 0, 
@@ -84,7 +82,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Item Code", 
    "length": 0, 
    "no_copy": 1, 
@@ -115,7 +112,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 1, 
    "label": "Variant Of", 
    "length": 0, 
    "no_copy": 0, 
@@ -144,7 +140,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Item Name", 
    "length": 0, 
    "no_copy": 0, 
@@ -173,7 +168,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Barcode", 
    "length": 0, 
    "no_copy": 1, 
@@ -201,7 +195,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
-   "in_standard_filter": 1, 
    "label": "Item Group", 
    "length": 0, 
    "no_copy": 0, 
@@ -232,7 +225,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Unit of Measure", 
    "length": 0, 
    "no_copy": 0, 
@@ -262,7 +254,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -288,7 +279,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Disabled", 
    "length": 0, 
    "no_copy": 0, 
@@ -318,7 +308,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Maintain Stock", 
    "length": 0, 
    "no_copy": 0, 
@@ -349,7 +338,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Opening Stock", 
    "length": 0, 
    "no_copy": 0, 
@@ -367,38 +355,37 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:(doc.__islocal && doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no && doc.opening_stock)", 
-   "fieldname": "valuation_rate", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Valuation Rate", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "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": 1, 
    "collapsible": 0, 
    "columns": 0, 
+   "depends_on": "eval:(doc.__islocal && doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no && doc.opening_stock)", 
+   "fieldname": "valuation_rate", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Valuation Rate", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "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, 
+   "columns": 0, 
    "fieldname": "standard_rate", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -406,7 +393,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Standard Selling Rate", 
    "length": 0, 
    "no_copy": 0, 
@@ -434,7 +420,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Is Fixed Asset", 
    "length": 0, 
    "no_copy": 0, 
@@ -463,7 +448,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Asset Category", 
    "length": 0, 
    "no_copy": 0, 
@@ -492,7 +476,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Image", 
    "length": 0, 
    "no_copy": 0, 
@@ -521,7 +504,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -549,7 +531,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Brand", 
    "length": 0, 
    "no_copy": 0, 
@@ -579,7 +560,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -610,7 +590,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Inventory", 
    "length": 0, 
    "no_copy": 0, 
@@ -641,7 +620,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Warehouse", 
    "length": 0, 
    "no_copy": 0, 
@@ -673,7 +651,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "End of Life", 
    "length": 0, 
    "no_copy": 0, 
@@ -704,7 +681,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Has Batch No", 
    "length": 0, 
    "no_copy": 0, 
@@ -737,7 +713,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Has Serial No", 
    "length": 0, 
    "no_copy": 0, 
@@ -769,7 +744,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Serial Number Series", 
    "length": 0, 
    "no_copy": 0, 
@@ -797,7 +771,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Material Request Type", 
    "length": 0, 
    "no_copy": 0, 
@@ -827,7 +800,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "oldfieldtype": "Column Break", 
@@ -857,7 +829,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Allow over delivery or receipt upto this percent", 
    "length": 0, 
    "no_copy": 0, 
@@ -887,7 +858,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Valuation Method", 
    "length": 0, 
    "no_copy": 0, 
@@ -916,7 +886,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Warranty Period (in days)", 
    "length": 0, 
    "no_copy": 0, 
@@ -947,7 +916,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Net Weight", 
    "length": 0, 
    "no_copy": 0, 
@@ -975,7 +943,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Weight UOM", 
    "length": 0, 
    "no_copy": 0, 
@@ -1005,7 +972,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Auto re-order", 
    "length": 0, 
    "no_copy": 0, 
@@ -1035,7 +1001,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Reorder level based on Warehouse", 
    "length": 0, 
    "no_copy": 0, 
@@ -1065,7 +1030,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Variants", 
    "length": 0, 
    "no_copy": 0, 
@@ -1096,7 +1060,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Has Variants", 
    "length": 0, 
    "no_copy": 1, 
@@ -1126,7 +1089,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Attributes", 
    "length": 0, 
    "no_copy": 1, 
@@ -1155,7 +1117,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Purchase Details", 
    "length": 0, 
    "no_copy": 0, 
@@ -1185,7 +1146,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Is Purchase Item", 
    "length": 0, 
    "no_copy": 0, 
@@ -1216,7 +1176,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Minimum Order Qty", 
    "length": 0, 
    "no_copy": 0, 
@@ -1245,7 +1204,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Safety Stock", 
    "length": 0, 
    "no_copy": 0, 
@@ -1275,7 +1233,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Lead Time in days", 
    "length": 0, 
    "no_copy": 0, 
@@ -1306,7 +1263,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Buying Cost Center", 
    "length": 0, 
    "no_copy": 0, 
@@ -1338,7 +1294,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Expense Account", 
    "length": 0, 
    "no_copy": 0, 
@@ -1369,7 +1324,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Unit of Measure Conversion", 
    "length": 0, 
    "no_copy": 0, 
@@ -1399,7 +1353,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "UOMs", 
    "length": 0, 
    "no_copy": 1, 
@@ -1430,7 +1383,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Last Purchase Rate", 
    "length": 0, 
    "no_copy": 1, 
@@ -1460,7 +1412,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Supplier Details", 
    "length": 0, 
    "no_copy": 0, 
@@ -1489,7 +1440,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Supplier", 
    "length": 0, 
    "no_copy": 0, 
@@ -1517,7 +1467,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Delivered by Supplier (Drop Ship)", 
    "length": 0, 
    "no_copy": 0, 
@@ -1546,7 +1495,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Manufacturer", 
    "length": 0, 
    "no_copy": 0, 
@@ -1575,7 +1523,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Manufacturer Part Number", 
    "length": 0, 
    "no_copy": 0, 
@@ -1603,7 +1550,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Item Code for Suppliers", 
    "length": 0, 
    "no_copy": 0, 
@@ -1633,7 +1579,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Supplier Items", 
    "length": 0, 
    "no_copy": 0, 
@@ -1661,7 +1606,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Sales Details", 
    "length": 0, 
    "no_copy": 0, 
@@ -1691,7 +1635,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Is Sales Item", 
    "length": 0, 
    "no_copy": 0, 
@@ -1721,7 +1664,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Publish in Hub", 
    "length": 0, 
    "no_copy": 0, 
@@ -1750,7 +1692,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Synced With Hub", 
    "length": 0, 
    "no_copy": 0, 
@@ -1779,7 +1720,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Income Account", 
    "length": 0, 
    "no_copy": 0, 
@@ -1808,7 +1748,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default Selling Cost Center", 
    "length": 0, 
    "no_copy": 0, 
@@ -1837,7 +1776,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Customer Item Codes", 
    "length": 0, 
    "no_copy": 0, 
@@ -1868,7 +1806,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Customer Items", 
    "length": 0, 
    "no_copy": 0, 
@@ -1897,7 +1834,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Max Discount (%)", 
    "length": 0, 
    "no_copy": 0, 
@@ -1926,7 +1862,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Item Tax", 
    "length": 0, 
    "no_copy": 0, 
@@ -1956,7 +1891,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Taxes", 
    "length": 0, 
    "no_copy": 0, 
@@ -1986,7 +1920,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Inspection Criteria", 
    "length": 0, 
    "no_copy": 0, 
@@ -2016,7 +1949,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Inspection Required before Purchase", 
    "length": 0, 
    "no_copy": 0, 
@@ -2046,7 +1978,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Inspection Required before Delivery", 
    "length": 0, 
    "no_copy": 0, 
@@ -2076,7 +2007,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Quality Parameters", 
    "length": 0, 
    "no_copy": 0, 
@@ -2107,7 +2037,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Manufacturing", 
    "length": 0, 
    "no_copy": 0, 
@@ -2137,7 +2066,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Default BOM", 
    "length": 0, 
    "no_copy": 1, 
@@ -2169,7 +2097,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Supply Raw Materials for Purchase", 
    "length": 0, 
    "no_copy": 0, 
@@ -2199,7 +2126,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -2226,7 +2152,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Customer Code", 
    "length": 0, 
    "no_copy": 1, 
@@ -2253,7 +2178,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Website", 
    "length": 0, 
    "no_copy": 0, 
@@ -2282,7 +2206,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Show in Website", 
    "length": 0, 
    "no_copy": 0, 
@@ -2310,7 +2233,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Show in Website (Variant)", 
    "length": 0, 
    "no_copy": 0, 
@@ -2339,7 +2261,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Route", 
    "length": 0, 
    "no_copy": 0, 
@@ -2369,7 +2290,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Weightage", 
    "length": 0, 
    "no_copy": 0, 
@@ -2398,7 +2318,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Slideshow", 
    "length": 0, 
    "no_copy": 0, 
@@ -2428,7 +2347,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Image", 
    "length": 0, 
    "no_copy": 0, 
@@ -2456,7 +2374,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Thumbnail", 
    "length": 0, 
    "no_copy": 0, 
@@ -2484,7 +2401,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -2512,7 +2428,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Website Warehouse", 
    "length": 0, 
    "no_copy": 0, 
@@ -2542,7 +2457,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Website Item Groups", 
    "length": 0, 
    "no_copy": 0, 
@@ -2572,7 +2486,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Website Specifications", 
    "length": 0, 
    "no_copy": 0, 
@@ -2600,7 +2513,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Copy From Item Group", 
    "length": 0, 
    "no_copy": 0, 
@@ -2628,7 +2540,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Website Specifications", 
    "length": 0, 
    "no_copy": 0, 
@@ -2657,7 +2568,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Website Description", 
    "length": 0, 
    "no_copy": 0, 
@@ -2684,7 +2594,6 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
    "label": "Total Projected Qty", 
    "length": 0, 
    "no_copy": 0, 
@@ -2713,7 +2622,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2016-12-27 12:17:44.227302", 
+ "modified": "2017-01-10 12:02:51.807965", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item", 
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 0ed6952..b21cc3b 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -42,9 +42,6 @@
 
 	get_party_item_code(args, item_doc, out)
 
-	if out.get("warehouse"):
-		out.update(get_bin_details(args.item_code, out.warehouse))	
-
 	if frappe.db.exists("Product Bundle", args.item_code):
 		valuation_rate = 0.0
 		bundled_items = frappe.get_doc("Product Bundle", args.item_code)
@@ -65,6 +62,9 @@
 
 	if args.customer and cint(args.is_pos):
 		out.update(get_pos_profile_item_details(args.company, args))
+		
+	if out.get("warehouse"):
+		out.update(get_bin_details(args.item_code, out.warehouse))
 
 	# update args with out, if key or value not exists
 	for key, value in out.iteritems():
@@ -143,7 +143,7 @@
 	user_default_warehouse = user_default_warehouse_list[0] \
 		if len(user_default_warehouse_list)==1 else ""
 
-	warehouse = user_default_warehouse or args.warehouse or item.default_warehouse
+	warehouse = user_default_warehouse or item.default_warehouse or args.warehouse
 
 	out = frappe._dict({
 		"item_code": item.name,
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index d5d6f9d..a8db4e0 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -102,7 +102,7 @@
 				"in_qty": 0.0, "in_val": 0.0,
 				"out_qty": 0.0, "out_val": 0.0,
 				"bal_qty": 0.0, "bal_val": 0.0,
-				"val_rate": 0.0, "uom": None
+				"val_rate": 0.0
 			})
 
 		qty_dict = iwb_map[(d.company, d.item_code, d.warehouse)]
@@ -129,6 +129,24 @@
 		qty_dict.val_rate = d.valuation_rate
 		qty_dict.bal_qty += qty_diff
 		qty_dict.bal_val += value_diff
+		
+	iwb_map = filter_items_with_no_transactions(iwb_map)
+
+	return iwb_map
+	
+def filter_items_with_no_transactions(iwb_map):
+	for (company, item, warehouse) in sorted(iwb_map):
+		qty_dict = iwb_map[(company, item, warehouse)]
+		
+		no_transactions = True
+		for key, val in qty_dict.items():
+			val = flt(val, 3)
+			qty_dict[key] = val
+			if key != "val_rate" and val:
+				no_transactions = False
+		
+		if no_transactions:
+			iwb_map.pop((company, item, warehouse))
 
 	return iwb_map