[fixed] frappe.require is now async :boom:
diff --git a/erpnext/accounts/doctype/c_form/c_form.js b/erpnext/accounts/doctype/c_form/c_form.js
index eed81cb..92cdb63 100644
--- a/erpnext/accounts/doctype/c_form/c_form.js
+++ b/erpnext/accounts/doctype/c_form/c_form.js
@@ -3,12 +3,12 @@
 
 //c-form js file
 // -----------------------------
-frappe.require("assets/erpnext/js/utils.js");
+
 
 cur_frm.fields_dict.invoices.grid.get_field("invoice_no").get_query = function(doc) {
 	return {
 		filters: {
-			"docstatus": 1, 
+			"docstatus": 1,
 			"customer": doc.customer,
 			"company": doc.company,
 			"c_form_applicable": 'Yes',
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index fc29bc7..bc337a1 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -3,7 +3,7 @@
 
 frappe.provide("erpnext.accounts");
 frappe.provide("erpnext.journal_entry");
-frappe.require("assets/erpnext/js/utils.js");
+
 
 frappe.ui.form.on("Journal Entry", {
 	refresh: function(frm) {
diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json
index 5659f1f..9255eda 100644
--- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json
+++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json
@@ -13,9 +13,10 @@
    "bold": 0, 
    "collapsible": 0, 
    "fieldname": "invoice_type", 
-   "fieldtype": "Data", 
+   "fieldtype": "Select", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Invoice Type", 
@@ -24,6 +25,7 @@
    "options": "Sales Invoice\nPurchase Invoice\nJournal Entry", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -36,17 +38,19 @@
    "bold": 0, 
    "collapsible": 0, 
    "fieldname": "invoice_number", 
-   "fieldtype": "Data", 
+   "fieldtype": "Dynamic Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Invoice Number", 
    "length": 0, 
    "no_copy": 0, 
-   "options": "", 
+   "options": "invoice_type", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -62,6 +66,7 @@
    "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Invoice Date", 
@@ -69,6 +74,7 @@
    "no_copy": 0, 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -84,6 +90,7 @@
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "", 
@@ -91,6 +98,7 @@
    "no_copy": 0, 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -106,6 +114,7 @@
    "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Amount", 
@@ -113,6 +122,7 @@
    "no_copy": 0, 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -128,6 +138,7 @@
    "fieldtype": "Currency", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Outstanding Amount", 
@@ -135,6 +146,7 @@
    "no_copy": 0, 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -145,21 +157,24 @@
  ], 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
+ "idx": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2015-11-16 06:29:51.516537", 
+ "modified": "2016-04-29 05:47:14.124370", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Payment Reconciliation Invoice", 
  "name_case": "", 
  "owner": "Administrator", 
  "permissions": [], 
+ "quick_entry": 1, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "sort_field": "modified", 
- "sort_order": "DESC"
+ "sort_order": "DESC", 
+ "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js
index ef373aa..c892738 100644
--- a/erpnext/accounts/page/financial_analytics/financial_analytics.js
+++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js
@@ -12,7 +12,7 @@
 
 };
 
-frappe.require("assets/erpnext/js/account_tree_grid.js");
+{% include "erpnext/public/js/account_tree_grid.js" %}
 
 erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
 	filters: [
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js
index 933b40e..a20d47c 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.js
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js
@@ -1,6 +1,8 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/financial_statements.js");
+frappe.require("assets/erpnext/js/financial_statements.js", function() {
+	frappe.query_reports["Balance Sheet"] = erpnext.financial_statements;
+});
 
-frappe.query_reports["Balance Sheet"] = erpnext.financial_statements;
+
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.js b/erpnext/accounts/report/cash_flow/cash_flow.js
index 464bd17..f5ddd15 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.js
+++ b/erpnext/accounts/report/cash_flow/cash_flow.js
@@ -1,12 +1,12 @@
 // Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
 // For license information, please see license.txt
 
-frappe.require("assets/erpnext/js/financial_statements.js");
+frappe.require("assets/erpnext/js/financial_statements.js", function() {
+	frappe.query_reports["Cash Flow"] = erpnext.financial_statements;
 
-frappe.query_reports["Cash Flow"] = erpnext.financial_statements;
-
-frappe.query_reports["Cash Flow"]["filters"].push({
-	"fieldname": "accumulated_values",
-	"label": __("Accumulated Values"),
-	"fieldtype": "Check"
-})
\ No newline at end of file
+	frappe.query_reports["Cash Flow"]["filters"].push({
+		"fieldname": "accumulated_values",
+		"label": __("Accumulated Values"),
+		"fieldtype": "Check"
+	});
+});
\ No newline at end of file
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
index 98a972b..91ec9d9 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
@@ -1,15 +1,12 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/financial_statements.js");
+frappe.require("assets/erpnext/js/financial_statements.js", function() {
+	frappe.query_reports["Profit and Loss Statement"] = $.extend({}, erpnext.financial_statements);
 
-frappe.query_reports["Profit and Loss Statement"] = $.extend({}, erpnext.financial_statements);
-
-frappe.query_reports["Profit and Loss Statement"]["filters"].push({
-	"fieldname": "accumulated_values",
-	"label": __("Accumulated Values"),
-	"fieldtype": "Check"
-});
-
-console.log(frappe.query_reports["Profit and Loss Statement"]);
-
+	frappe.query_reports["Profit and Loss Statement"]["filters"].push({
+		"fieldname": "accumulated_values",
+		"label": __("Accumulated Values"),
+		"fieldtype": "Check"
+	});
+});
\ No newline at end of file
diff --git a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js
index 4b34ae5..cc00b2a 100644
--- a/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js
+++ b/erpnext/accounts/report/purchase_invoice_trends/purchase_invoice_trends.js
@@ -1,8 +1,8 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/purchase_trends_filters.js");
-
-frappe.query_reports["Purchase Invoice Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
+frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() {
+	frappe.query_reports["Purchase Invoice Trends"] = {
+		filters: get_filters()
+	}
+});
\ No newline at end of file
diff --git a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js
index 471e7ba..0f92223 100644
--- a/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js
+++ b/erpnext/accounts/report/sales_invoice_trends/sales_invoice_trends.js
@@ -1,8 +1,8 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/sales_trends_filters.js");
-
-frappe.query_reports["Sales Invoice Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
+frappe.require("assets/erpnext/js/sales_trends_filters.js", function() {
+	frappe.query_reports["Sales Invoice Trends"] = {
+		filters: get_filters()
+	}
+});
\ No newline at end of file
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.js b/erpnext/accounts/report/trial_balance/trial_balance.js
index 97c8f6c..a20b1cb 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.js
+++ b/erpnext/accounts/report/trial_balance/trial_balance.js
@@ -1,65 +1,66 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/financial_statements.js");
-
-frappe.query_reports["Trial Balance"] = {
-	"filters": [
-		{
-			"fieldname": "company",
-			"label": __("Company"),
-			"fieldtype": "Link",
-			"options": "Company",
-			"default": frappe.defaults.get_user_default("Company"),
-			"reqd": 1
-		},
-		{
-			"fieldname": "fiscal_year",
-			"label": __("Fiscal Year"),
-			"fieldtype": "Link",
-			"options": "Fiscal Year",
-			"default": frappe.defaults.get_user_default("fiscal_year"),
-			"reqd": 1,
-			"on_change": function(query_report) {
-				var fiscal_year = query_report.get_values().fiscal_year;
-				if (!fiscal_year) {
-					return;
+frappe.require("assets/erpnext/js/financial_statements.js", function() {
+	frappe.query_reports["Trial Balance"] = {
+		"filters": [
+			{
+				"fieldname": "company",
+				"label": __("Company"),
+				"fieldtype": "Link",
+				"options": "Company",
+				"default": frappe.defaults.get_user_default("Company"),
+				"reqd": 1
+			},
+			{
+				"fieldname": "fiscal_year",
+				"label": __("Fiscal Year"),
+				"fieldtype": "Link",
+				"options": "Fiscal Year",
+				"default": frappe.defaults.get_user_default("fiscal_year"),
+				"reqd": 1,
+				"on_change": function(query_report) {
+					var fiscal_year = query_report.get_values().fiscal_year;
+					if (!fiscal_year) {
+						return;
+					}
+					frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+						var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+						query_report.filters_by_name.from_date.set_input(fy.year_start_date);
+						query_report.filters_by_name.to_date.set_input(fy.year_end_date);
+						query_report.trigger_refresh();
+					});
 				}
-				frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
-					var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
-					query_report.filters_by_name.from_date.set_input(fy.year_start_date);
-					query_report.filters_by_name.to_date.set_input(fy.year_end_date);
-					query_report.trigger_refresh();
-				});
-			}
-		},
-		{
-			"fieldname": "from_date",
-			"label": __("From Date"),
-			"fieldtype": "Date",
-			"default": frappe.defaults.get_user_default("year_start_date"),
-		},
-		{
-			"fieldname": "to_date",
-			"label": __("To Date"),
-			"fieldtype": "Date",
-			"default": frappe.defaults.get_user_default("year_end_date"),
-		},
-		{
-			"fieldname": "with_period_closing_entry",
-			"label": __("Period Closing Entry"),
-			"fieldtype": "Check",
-			"default": 1
-		},
-		{
-			"fieldname": "show_zero_values",
-			"label": __("Show zero values"),
-			"fieldtype": "Check"
-		},
-	],
-	"formatter": erpnext.financial_statements.formatter,
-	"tree": true,
-	"name_field": "account",
-	"parent_field": "parent_account",
-	"initial_depth": 3
-}
+			},
+			{
+				"fieldname": "from_date",
+				"label": __("From Date"),
+				"fieldtype": "Date",
+				"default": frappe.defaults.get_user_default("year_start_date"),
+			},
+			{
+				"fieldname": "to_date",
+				"label": __("To Date"),
+				"fieldtype": "Date",
+				"default": frappe.defaults.get_user_default("year_end_date"),
+			},
+			{
+				"fieldname": "with_period_closing_entry",
+				"label": __("Period Closing Entry"),
+				"fieldtype": "Check",
+				"default": 1
+			},
+			{
+				"fieldname": "show_zero_values",
+				"label": __("Show zero values"),
+				"fieldtype": "Check"
+			},
+		],
+		"formatter": erpnext.financial_statements.formatter,
+		"tree": true,
+		"name_field": "account",
+		"parent_field": "parent_account",
+		"initial_depth": 3
+	}
+});
+
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index b38b90e..8617a26 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -4,9 +4,8 @@
 frappe.provide("erpnext.buying");
 
 cur_frm.cscript.tax_table = "Purchase Taxes and Charges";
-{% include 'erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %}
 
-frappe.require("assets/erpnext/js/controllers/transaction.js");
+{% include 'erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js' %}
 
 cur_frm.email_field = "contact_email";
 
@@ -129,12 +128,12 @@
 				item.rejected_qty = flt(item.received_qty - item.qty, precision("rejected_qty", item));
 			}
 		}
-		
+
 		this._super(doc, cdt, cdn);
 		this.conversion_factor(doc, cdt, cdn);
-		
+
 	},
-	
+
 	received_qty: function(doc, cdt, cdn) {
 		var item = frappe.get_doc(cdt, cdn);
 		frappe.model.round_floats_in(item, ["qty", "received_qty"]);
@@ -142,7 +141,7 @@
 		item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
 		this.qty(doc, cdt, cdn);
 	},
-	
+
 	rejected_qty: function(doc, cdt, cdn) {
 		var item = frappe.get_doc(cdt, cdn);
 		frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
@@ -152,7 +151,7 @@
 						__(frappe.meta.get_label(item.doctype, "received_qty", item.name))]));
 			item.qty = item.rejected_qty = 0.0;
 		} else {
-			
+
 			item.qty = flt(item.received_qty - item.rejected_qty, precision("qty", item));
 		}
 
@@ -236,7 +235,7 @@
 		erpnext.utils.get_address_display(this.frm, "shipping_address",
 			"shipping_address_display", is_your_company_address=true)
 	},
-	
+
 	tc_name: function() {
 		this.get_terms();
 	}
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
index b8002dd..7218531 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -4,7 +4,7 @@
 
 {% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
 
-frappe.require("assets/erpnext/js/utils.js");
+
 
 frappe.ui.form.on("Request for Quotation",{
 	setup: function(frm){
diff --git a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js
index dcf1df1..f7fe90f 100644
--- a/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js
+++ b/erpnext/buying/report/purchase_order_trends/purchase_order_trends.js
@@ -1,8 +1,8 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/purchase_trends_filters.js");
-
-frappe.query_reports["Purchase Order Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
+frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() {
+	frappe.query_reports["Purchase Order Trends"] = {
+		filters: get_filters()
+	}
+});
\ No newline at end of file
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index 337b631..c918dad 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -2,7 +2,7 @@
 // License: GNU General Public License v3. See license.txt
 
 frappe.provide("erpnext.crm");
-frappe.require("assets/erpnext/js/utils.js");
+
 cur_frm.email_field = "contact_email";
 frappe.ui.form.on("Opportunity", {
 	customer: function(frm) {
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.js b/erpnext/hr/doctype/upload_attendance/upload_attendance.js
index 47ffec0..c49720c 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.js
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.js
@@ -2,7 +2,7 @@
 // License: GNU General Public License v3. See license.txt
 
 
-frappe.require("assets/erpnext/js/utils.js");
+
 frappe.provide("erpnext.hr");
 
 erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js
index 5b97397..710862b 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js
@@ -1,7 +1,7 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/utils.js");
+
 
 cur_frm.cscript.onload = function(doc) {
 	cur_frm.set_value("company", frappe.defaults.get_user_default("Company"))
diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js
index 5c1fb0d..9148397 100644
--- a/erpnext/projects/doctype/project/project.js
+++ b/erpnext/projects/doctype/project/project.js
@@ -43,20 +43,9 @@
 				});
 			}
 
+			frm.dashboard.show_heatmap = true;
+			frm.dashboard.heatmap_message = __('This is based on the Time Logs created against this project');
 			frm.dashboard.show_dashboard();
-			// frm.dashboard.add_section(frappe.render_template('project_dashboard', {project: frm.doc}));
-
-			// var bars = [];
-			// bars.push({
-			// 	'title': __('Percent Complete'),
-			// 	'width': (frm.doc.percent_complete || 1)  + '%',
-			// 	'progress_class': 'progress-bar-success'
-			// })
-			//
-			// var message = __("{0}% complete", [frm.doc.percent_complete]);
-			//
-			// frm.dashboard.add_progress(__('Status'), bars, message);
-
 		}
 
 	}
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index 2cca7e2..c5808a2 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -154,8 +154,17 @@
 	from frappe.desk.notifications import get_open_count
 	return {
 		'count': get_open_count('Project', name),
+		'timeline_data': get_timeline_data(name)
 	}
 
+def get_timeline_data(name):
+	'''Return timeline for attendance'''
+	return dict(frappe.db.sql('''select unix_timestamp(from_time), count(*)
+		from `tabTime Log` where project=%s
+			and from_time > date_sub(curdate(), interval 1 year)
+			and docstatus < 2
+			group by date(from_time)''', name))
+
 def get_project_list(doctype, txt, filters, limit_start, limit_page_length=20):
 	return frappe.db.sql('''select distinct project.*
 		from tabProject project, `tabProject User` project_user
diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json
index ef61d41..25d62c4 100644
--- a/erpnext/projects/doctype/time_log/time_log.json
+++ b/erpnext/projects/doctype/time_log/time_log.json
@@ -461,7 +461,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "eval:doc.for_manufacturing", 
+   "depends_on": "for_manufacturing", 
    "fieldname": "section_break_11", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -645,7 +645,8 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "depends_on": "", 
+   "collapsible_depends_on": "", 
+   "depends_on": "costing_rate", 
    "fieldname": "section_break_24", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -653,6 +654,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "label": "Cost", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -748,6 +750,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "default": "0", 
+   "depends_on": "billable", 
    "description": "", 
    "fieldname": "billing_rate", 
    "fieldtype": "Currency", 
@@ -801,6 +804,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "default": "0", 
+   "depends_on": "billable", 
    "description": "Will be updated only if Time Log is 'Billable'", 
    "fieldname": "billing_amount", 
    "fieldtype": "Currency", 
@@ -935,7 +939,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-04-29 03:45:50.096299", 
+ "modified": "2016-04-29 05:19:18.247260", 
  "modified_by": "Administrator", 
  "module": "Projects", 
  "name": "Time Log", 
diff --git a/erpnext/public/build.json b/erpnext/public/build.json
index ab0f673..1831907 100644
--- a/erpnext/public/build.json
+++ b/erpnext/public/build.json
@@ -11,15 +11,20 @@
 		"public/js/feature_setup.js",
 		"public/js/utils.js",
 		"public/js/queries.js",
+		"public/js/sms_manager.js",
 		"public/js/utils/party.js",
 		"public/js/templates/address_list.html",
 		"public/js/templates/contact_list.html",
+		"public/js/controllers/stock_controller.js",
+		"public/js/controllers/taxes_and_totals.js",
+		"public/js/controllers/transaction.js",
 		"public/js/pos/pos.html",
 		"public/js/pos/pos_bill_item.html",
 		"public/js/pos/pos_item.html",
 		"public/js/pos/pos_tax_row.html",
 		"public/js/pos/pos.js",
-		"public/js/templates/item_selector.html"
+		"public/js/templates/item_selector.html",
+		"public/js/utils/item_selector.js"
 	],
 	"js/item-dashboard.min.js": [
 		"stock/dashboard/item_dashboard.html",
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index b4e712a..1a234a3 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -1,9 +1,6 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.provide("erpnext");
-frappe.require("assets/erpnext/js/controllers/stock_controller.js");
-
 erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
 	calculate_taxes_and_totals: function(update_paid_amount) {
 		this.discount_amount_applied = false;
@@ -59,7 +56,7 @@
 						"to_currency": company_currency
 					}));
 			}
-			
+
 		}
 	},
 
@@ -256,7 +253,7 @@
 					me.round_off_totals(tax);
 
 					// adjust Discount Amount loss in last tax iteration
-					if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied 
+					if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied
 							&& me.frm.doc.apply_discount_on == "Grand Total" && me.frm.doc.discount_amount)
 						me.adjust_discount_amount_loss(tax);
 				}
@@ -321,10 +318,10 @@
 		tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
 			discount_amount_loss, precision("tax_amount", tax));
 		tax.total = flt(tax.total + discount_amount_loss, precision("total", tax));
-		
+
 		this.set_in_company_currency(tax, ["total", "tax_amount_after_discount_amount"]);
 	},
-	
+
 	manipulate_grand_total_for_inclusive_tax: function() {
 		var me = this;
 		// if fully inclusive taxes and diff
@@ -342,8 +339,8 @@
 					last_tax.tax_amount += diff;
 					last_tax.tax_amount_after_discount += diff;
 					last_tax.total += diff;
-					
-					this.set_in_company_currency(last_tax, 
+
+					this.set_in_company_currency(last_tax,
 						["total", "tax_amount", "tax_amount_after_discount_amount"]);
 				}
 			}
@@ -392,14 +389,14 @@
 
 		// rounded totals
 		if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
-			this.frm.doc.rounded_total = round_based_on_smallest_currency_fraction(this.frm.doc.grand_total, 
+			this.frm.doc.rounded_total = round_based_on_smallest_currency_fraction(this.frm.doc.grand_total,
 				this.frm.doc.currency, precision("rounded_total"));
 		}
 		if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
 			var company_currency = this.get_company_currency();
-			
-			this.frm.doc.base_rounded_total = 
-				round_based_on_smallest_currency_fraction(this.frm.doc.base_grand_total, 
+
+			this.frm.doc.base_rounded_total =
+				round_based_on_smallest_currency_fraction(this.frm.doc.base_grand_total,
 					company_currency, precision("base_rounded_total"));
 		}
 	},
@@ -497,28 +494,28 @@
 
 		this.calculate_outstanding_amount(update_paid_amount);
 	},
-	
+
 	calculate_outstanding_amount: function(update_paid_amount) {
 		// NOTE:
 		// paid_amount and write_off_amount is only for POS Invoice
 		// total_advance is only for non POS Invoice
 		if(this.frm.doc.is_return || this.frm.doc.docstatus > 0) return;
-		
+
 		frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
-		if(this.frm.doc.party_account_currency == this.frm.doc.currency) {	
-			var total_amount_to_pay = flt((this.frm.doc.grand_total - this.frm.doc.total_advance 
+		if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
+			var total_amount_to_pay = flt((this.frm.doc.grand_total - this.frm.doc.total_advance
 				- this.frm.doc.write_off_amount), precision("grand_total"));
 		} else {
 			var total_amount_to_pay = flt(
-				(flt(this.frm.doc.grand_total*this.frm.doc.conversion_rate, precision("grand_total")) 
-					- this.frm.doc.total_advance - this.frm.doc.base_write_off_amount), 
+				(flt(this.frm.doc.grand_total*this.frm.doc.conversion_rate, precision("grand_total"))
+					- this.frm.doc.total_advance - this.frm.doc.base_write_off_amount),
 				precision("base_grand_total")
 			);
 		}
-		
+
 		if(this.frm.doc.doctype == "Sales Invoice" || this.frm.doc.doctype == "Purchase Invoice") {
 			frappe.model.round_floats_in(this.frm.doc, ["paid_amount"]);
-			
+
 			if(this.frm.doc.is_pos || this.frm.doc.is_paid) {
 				if(!this.frm.doc.paid_amount || update_paid_amount===undefined || update_paid_amount) {
 					this.frm.doc.paid_amount = flt(total_amount_to_pay);
@@ -529,16 +526,16 @@
 			this.set_in_company_currency(this.frm.doc, ["paid_amount"]);
 			this.frm.refresh_field("paid_amount");
 			this.frm.refresh_field("base_paid_amount");
-			
-			var paid_amount = (this.frm.doc.party_account_currency == this.frm.doc.currency) ? 
+
+			var paid_amount = (this.frm.doc.party_account_currency == this.frm.doc.currency) ?
 				this.frm.doc.paid_amount : this.frm.doc.base_paid_amount;
-			
-			var outstanding_amount =  flt(total_amount_to_pay - flt(paid_amount), 
+
+			var outstanding_amount =  flt(total_amount_to_pay - flt(paid_amount),
 				precision("outstanding_amount"));
-				
+
 		} else if(this.frm.doc.doctype == "Purchase Invoice") {
 			var outstanding_amount = flt(total_amount_to_pay, precision("outstanding_amount"));
-		}		
+		}
 		this.frm.set_value("outstanding_amount", outstanding_amount);
 	}
 })
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 8e512e8..99036aa 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1,13 +1,85 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.provide("erpnext");
-frappe.require([
-	"assets/erpnext/js/controllers/taxes_and_totals.js",
-	"assets/erpnext/js/utils.js",
-	"assets/erpnext/js/utils/item_selector.js"]);
-
 erpnext.TransactionController = erpnext.taxes_and_totals.extend({
+	setup: function() {
+		frappe.ui.form.on(this.frm.doctype + " Item", "rate", function(frm, cdt, cdn) {
+			var item = frappe.get_doc(cdt, cdn);
+			frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
+
+			if(item.price_list_rate) {
+				item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item));
+			} else {
+				item.discount_percentage = 0.0;
+			}
+
+			cur_frm.cscript.set_gross_profit(item);
+			cur_frm.cscript.calculate_taxes_and_totals();
+		})
+
+		frappe.ui.form.on(this.frm.cscript.tax_table, "rate", function(frm, cdt, cdn) {
+			cur_frm.cscript.calculate_taxes_and_totals();
+		})
+
+		frappe.ui.form.on(this.frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) {
+			cur_frm.cscript.calculate_taxes_and_totals();
+		})
+
+		frappe.ui.form.on(this.frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) {
+			cur_frm.cscript.calculate_taxes_and_totals();
+		})
+
+		frappe.ui.form.on(this.frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
+			cur_frm.cscript.set_dynamic_labels();
+			cur_frm.cscript.calculate_taxes_and_totals();
+		})
+
+		frappe.ui.form.on(this.frm.doctype, "apply_discount_on", function(frm) {
+			if(frm.doc.additional_discount_percentage) {
+				frm.trigger("additional_discount_percentage");
+			} else {
+				cur_frm.cscript.calculate_taxes_and_totals();
+			}
+		})
+
+		frappe.ui.form.on(this.frm.doctype, "additional_discount_percentage", function(frm) {
+			if (frm.via_discount_amount) {
+				return;
+			}
+
+			if(!frm.doc.apply_discount_on) {
+				frappe.msgprint(__("Please set 'Apply Additional Discount On'"));
+				return
+			}
+
+			frm.via_discount_percentage = true;
+
+			if(frm.doc.additional_discount_percentage && frm.doc.discount_amount) {
+				// Reset discount amount and net / grand total
+				frm.set_value("discount_amount", 0);
+			}
+
+			var total = flt(frm.doc[frappe.model.scrub(frm.doc.apply_discount_on)]);
+			var discount_amount = flt(total*flt(frm.doc.additional_discount_percentage) / 100,
+				precision("discount_amount"));
+
+			frm.set_value("discount_amount", discount_amount);
+			delete frm.via_discount_percentage;
+		});
+
+		frappe.ui.form.on(this.frm.doctype, "discount_amount", function(frm) {
+			frm.cscript.set_dynamic_labels();
+
+			if (!frm.via_discount_percentage) {
+				frm.via_discount_amount = true;
+				frm.set_value("additional_discount_percentage", 0);
+				delete frm.via_discount_amount;
+			}
+
+			frm.cscript.calculate_taxes_and_totals();
+		});
+
+	},
 	onload: function() {
 		var me = this;
 		//this.frm.show_print_first = true;
@@ -128,7 +200,6 @@
 	},
 
 	send_sms: function() {
-		frappe.require("assets/erpnext/js/sms_manager.js");
 		var sms_man = new SMSManager(this.frm.doc);
 	},
 
@@ -911,80 +982,4 @@
 
 
 
-});
-
-frappe.ui.form.on(cur_frm.doctype + " Item", "rate", function(frm, cdt, cdn) {
-	var item = frappe.get_doc(cdt, cdn);
-	frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
-
-	if(item.price_list_rate) {
-		item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item));
-	} else {
-		item.discount_percentage = 0.0;
-	}
-
-	cur_frm.cscript.set_gross_profit(item);
-	cur_frm.cscript.calculate_taxes_and_totals();
-})
-
-frappe.ui.form.on(cur_frm.cscript.tax_table, "rate", function(frm, cdt, cdn) {
-	cur_frm.cscript.calculate_taxes_and_totals();
-})
-
-frappe.ui.form.on(cur_frm.cscript.tax_table, "tax_amount", function(frm, cdt, cdn) {
-	cur_frm.cscript.calculate_taxes_and_totals();
-})
-
-frappe.ui.form.on(cur_frm.cscript.tax_table, "row_id", function(frm, cdt, cdn) {
-	cur_frm.cscript.calculate_taxes_and_totals();
-})
-
-frappe.ui.form.on(cur_frm.cscript.tax_table, "included_in_print_rate", function(frm, cdt, cdn) {
-	cur_frm.cscript.set_dynamic_labels();
-	cur_frm.cscript.calculate_taxes_and_totals();
-})
-
-frappe.ui.form.on(cur_frm.doctype, "apply_discount_on", function(frm) {
-	if(frm.doc.additional_discount_percentage) {
-		frm.trigger("additional_discount_percentage");
-	} else {
-		cur_frm.cscript.calculate_taxes_and_totals();
-	}
-})
-
-frappe.ui.form.on(cur_frm.doctype, "additional_discount_percentage", function(frm) {
-	if (frm.via_discount_amount) {
-		return;
-	}
-
-	if(!frm.doc.apply_discount_on) {
-		frappe.msgprint(__("Please set 'Apply Additional Discount On'"));
-		return
-	}
-
-	frm.via_discount_percentage = true;
-
-	if(frm.doc.additional_discount_percentage && frm.doc.discount_amount) {
-		// Reset discount amount and net / grand total
-		frm.set_value("discount_amount", 0);
-	}
-
-	var total = flt(frm.doc[frappe.model.scrub(frm.doc.apply_discount_on)]);
-	var discount_amount = flt(total*flt(frm.doc.additional_discount_percentage) / 100,
-		precision("discount_amount"));
-
-	frm.set_value("discount_amount", discount_amount);
-	delete frm.via_discount_percentage;
-});
-
-frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) {
-	frm.cscript.set_dynamic_labels();
-
-	if (!frm.via_discount_percentage) {
-		frm.via_discount_amount = true;
-		frm.set_value("additional_discount_percentage", 0);
-		delete frm.via_discount_amount;
-	}
-
-	frm.cscript.calculate_taxes_and_totals();
-});
+});
\ No newline at end of file
diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js
index a8229ba..e9f9758 100644
--- a/erpnext/public/js/stock_analytics.js
+++ b/erpnext/public/js/stock_analytics.js
@@ -1,213 +1,214 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/stock_grid_report.js");
+frappe.require("assets/erpnext/js/stock_grid_report.js", function() {
+	erpnext.StockAnalytics = erpnext.StockGridReport.extend({
+		init: function(wrapper, opts) {
+			var args = {
+				title: __("Stock Analytics"),
+				page: wrapper,
+				parent: $(wrapper).find('.layout-main'),
+				page: wrapper.page,
+				doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
+					"Fiscal Year", "Serial No"],
+				tree_grid: {
+					show: true,
+					parent_field: "parent_item_group",
+					formatter: function(item) {
+						if(!item.is_group) {
+							return repl("<a \
+								onclick='frappe.cur_grid_report.show_stock_ledger(\"%(value)s\")'>\
+								%(value)s</a>", {
+									value: item.name,
+								});
+						} else {
+							return item.name;
+						}
 
-erpnext.StockAnalytics = erpnext.StockGridReport.extend({
-	init: function(wrapper, opts) {
-		var args = {
-			title: __("Stock Analytics"),
-			page: wrapper,
-			parent: $(wrapper).find('.layout-main'),
-			page: wrapper.page,
-			doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand",
-				"Fiscal Year", "Serial No"],
-			tree_grid: {
-				show: true,
-				parent_field: "parent_item_group",
-				formatter: function(item) {
-					if(!item.is_group) {
-						return repl("<a \
-							onclick='frappe.cur_grid_report.show_stock_ledger(\"%(value)s\")'>\
-							%(value)s</a>", {
-								value: item.name,
-							});
-					} else {
-						return item.name;
 					}
-
-				}
-			},
-		}
-
-		if(opts) $.extend(args, opts);
-
-		this._super(args);
-	},
-	setup_columns: function() {
-		var std_columns = [
-			{id: "_check", name: __("Plot"), field: "_check", width: 30,
-				formatter: this.check_formatter},
-			{id: "name", name: __("Item"), field: "name", width: 300,
-				formatter: this.tree_formatter},
-			{id: "brand", name: __("Brand"), field: "brand", width: 100},
-			{id: "stock_uom", name: __("UOM"), field: "stock_uom", width: 100},
-			{id: "opening", name: __("Opening"), field: "opening", hidden: true,
-				formatter: this.currency_formatter}
-		];
-
-		this.make_date_range_columns();
-		this.columns = std_columns.concat(this.columns);
-	},
-	filters: [
-		{fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty",
-			options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}],
-			filter: function(val, item, opts, me) {
-				return me.apply_zero_filter(val, item, opts, me);
-			}},
-		{fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand",
-			default_value: __("Select Brand..."), filter: function(val, item, opts) {
-				return val == opts.default_value || item.brand == val || item._show;
-			}, link_formatter: {filter_input: "brand"}},
-		{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse",
-			default_value: __("Select Warehouse...")},
-		{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
-		{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
-		{fieldtype:"Select", label: __("Range"), fieldname: "range",
-			options:[
-				{label:__("Daily"), value:"Daily"},
-				{label:__("Weekly"), value:"Weekly"},
-				{label:__("Monthly"), value:"Monthly"},
-				{label:__("Quarterly"), value:"Quarterly"},
-				{label:__("Yearly"), value:"Yearly"},
-			]}
-	],
-	setup_filters: function() {
-		var me = this;
-		this._super();
-
-		this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]);
-
-		this.show_zero_check();
-		this.setup_plot_check();
-	},
-	init_filter_values: function() {
-		this._super();
-		this.filter_inputs.range && this.filter_inputs.range.val('Monthly');
-	},
-	prepare_data: function() {
-		var me = this;
-
-		if(!this.data) {
-			var items = this.prepare_tree("Item", "Item Group");
-
-			me.parent_map = {};
-			me.item_by_name = {};
-			me.data = [];
-
-			$.each(items, function(i, v) {
-				var d = copy_dict(v);
-
-				me.data.push(d);
-				me.item_by_name[d.name] = d;
-				if(d.parent_item_group) {
-					me.parent_map[d.name] = d.parent_item_group;
-				}
-				me.reset_item_values(d);
-			});
-			this.set_indent();
-			this.data[0].checked = true;
-		} else {
-			// otherwise, only reset values
-			$.each(this.data, function(i, d) {
-				me.reset_item_values(d);
-				d["closing_qty_value"] = 0;
-			});
-		}
-
-		this.prepare_balances();
-		this.update_groups();
-
-	},
-	prepare_balances: function() {
-		var me = this;
-		var from_date = dateutil.str_to_obj(this.from_date);
-		var to_date = dateutil.str_to_obj(this.to_date);
-		var data = frappe.report_dump.data["Stock Ledger Entry"];
-
-		this.item_warehouse = {};
-		this.serialized_buying_rates = this.get_serialized_buying_rates();
-
-		for(var i=0, j=data.length; i<j; i++) {
-			var sl = data[i];
-			sl.posting_datetime = sl.posting_date + " " + sl.posting_time;
-			var posting_datetime = dateutil.str_to_obj(sl.posting_datetime);
-
-			if(me.is_default("warehouse") ? true : me.warehouse == sl.warehouse) {
-				var item = me.item_by_name[sl.item_code];
-				if(item.closing_qty_value==undefined) item.closing_qty_value = 0;
-
-				if(me.value_or_qty!="Quantity") {
-					var wh = me.get_item_warehouse(sl.warehouse, sl.item_code);
-					var valuation_method = item.valuation_method ?
-						item.valuation_method : sys_defaults.valuation_method;
-					var is_fifo = valuation_method == "FIFO";
-
-					if(sl.voucher_type=="Stock Reconciliation") {
-						var diff = (sl.qty_after_transaction * sl.valuation_rate) - item.closing_qty_value;
-						wh.fifo_stack = [[sl.qty_after_transaction, sl.valuation_rate, sl.posting_date]];
-						wh.balance_qty = sl.qty_after_transaction;
-						wh.balance_value = sl.valuation_rate * sl.qty_after_transaction;
-					} else {
-						var diff = me.get_value_diff(wh, sl, is_fifo);
-					}
-				} else {
-					if(sl.voucher_type=="Stock Reconciliation") {
-						var diff = sl.qty_after_transaction - item.closing_qty_value;
-					} else {
-						var diff = sl.qty;
-					}
-				}
-
-				if(posting_datetime < from_date) {
-					item.opening += diff;
-				} else if(posting_datetime <= to_date) {
-					item[me.column_map[sl.posting_date].field] += diff;
-				} else {
-					break;
-				}
-
-				item.closing_qty_value += diff;
+				},
 			}
-		}
-	},
-	update_groups: function() {
-		var me = this;
-		$.each(this.data, function(i, item) {
-			// update groups
-			if(!item.is_group && me.apply_filter(item, "brand")) {
-				var balance = item.opening;
-				$.each(me.columns, function(i, col) {
-					if(col.formatter==me.currency_formatter && !col.hidden) {
-						item[col.field] = balance + item[col.field];
-						balance = item[col.field];
-					}
-				});
 
-				var parent = me.parent_map[item.name];
-				while(parent) {
-					parent_group = me.item_by_name[parent];
-					$.each(me.columns, function(c, col) {
-						if (col.formatter == me.currency_formatter) {
-							parent_group[col.field] =
-								flt(parent_group[col.field])
-								+ flt(item[col.field]);
+			if(opts) $.extend(args, opts);
+
+			this._super(args);
+		},
+		setup_columns: function() {
+			var std_columns = [
+				{id: "_check", name: __("Plot"), field: "_check", width: 30,
+					formatter: this.check_formatter},
+				{id: "name", name: __("Item"), field: "name", width: 300,
+					formatter: this.tree_formatter},
+				{id: "brand", name: __("Brand"), field: "brand", width: 100},
+				{id: "stock_uom", name: __("UOM"), field: "stock_uom", width: 100},
+				{id: "opening", name: __("Opening"), field: "opening", hidden: true,
+					formatter: this.currency_formatter}
+			];
+
+			this.make_date_range_columns();
+			this.columns = std_columns.concat(this.columns);
+		},
+		filters: [
+			{fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty",
+				options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}],
+				filter: function(val, item, opts, me) {
+					return me.apply_zero_filter(val, item, opts, me);
+				}},
+			{fieldtype:"Select", label: __("Brand"), link:"Brand", fieldname: "brand",
+				default_value: __("Select Brand..."), filter: function(val, item, opts) {
+					return val == opts.default_value || item.brand == val || item._show;
+				}, link_formatter: {filter_input: "brand"}},
+			{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse",
+				default_value: __("Select Warehouse...")},
+			{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
+			{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
+			{fieldtype:"Select", label: __("Range"), fieldname: "range",
+				options:[
+					{label:__("Daily"), value:"Daily"},
+					{label:__("Weekly"), value:"Weekly"},
+					{label:__("Monthly"), value:"Monthly"},
+					{label:__("Quarterly"), value:"Quarterly"},
+					{label:__("Yearly"), value:"Yearly"},
+				]}
+		],
+		setup_filters: function() {
+			var me = this;
+			this._super();
+
+			this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]);
+
+			this.show_zero_check();
+			this.setup_plot_check();
+		},
+		init_filter_values: function() {
+			this._super();
+			this.filter_inputs.range && this.filter_inputs.range.val('Monthly');
+		},
+		prepare_data: function() {
+			var me = this;
+
+			if(!this.data) {
+				var items = this.prepare_tree("Item", "Item Group");
+
+				me.parent_map = {};
+				me.item_by_name = {};
+				me.data = [];
+
+				$.each(items, function(i, v) {
+					var d = copy_dict(v);
+
+					me.data.push(d);
+					me.item_by_name[d.name] = d;
+					if(d.parent_item_group) {
+						me.parent_map[d.name] = d.parent_item_group;
+					}
+					me.reset_item_values(d);
+				});
+				this.set_indent();
+				this.data[0].checked = true;
+			} else {
+				// otherwise, only reset values
+				$.each(this.data, function(i, d) {
+					me.reset_item_values(d);
+					d["closing_qty_value"] = 0;
+				});
+			}
+
+			this.prepare_balances();
+			this.update_groups();
+
+		},
+		prepare_balances: function() {
+			var me = this;
+			var from_date = dateutil.str_to_obj(this.from_date);
+			var to_date = dateutil.str_to_obj(this.to_date);
+			var data = frappe.report_dump.data["Stock Ledger Entry"];
+
+			this.item_warehouse = {};
+			this.serialized_buying_rates = this.get_serialized_buying_rates();
+
+			for(var i=0, j=data.length; i<j; i++) {
+				var sl = data[i];
+				sl.posting_datetime = sl.posting_date + " " + sl.posting_time;
+				var posting_datetime = dateutil.str_to_obj(sl.posting_datetime);
+
+				if(me.is_default("warehouse") ? true : me.warehouse == sl.warehouse) {
+					var item = me.item_by_name[sl.item_code];
+					if(item.closing_qty_value==undefined) item.closing_qty_value = 0;
+
+					if(me.value_or_qty!="Quantity") {
+						var wh = me.get_item_warehouse(sl.warehouse, sl.item_code);
+						var valuation_method = item.valuation_method ?
+							item.valuation_method : sys_defaults.valuation_method;
+						var is_fifo = valuation_method == "FIFO";
+
+						if(sl.voucher_type=="Stock Reconciliation") {
+							var diff = (sl.qty_after_transaction * sl.valuation_rate) - item.closing_qty_value;
+							wh.fifo_stack = [[sl.qty_after_transaction, sl.valuation_rate, sl.posting_date]];
+							wh.balance_qty = sl.qty_after_transaction;
+							wh.balance_value = sl.valuation_rate * sl.qty_after_transaction;
+						} else {
+							var diff = me.get_value_diff(wh, sl, is_fifo);
+						}
+					} else {
+						if(sl.voucher_type=="Stock Reconciliation") {
+							var diff = sl.qty_after_transaction - item.closing_qty_value;
+						} else {
+							var diff = sl.qty;
+						}
+					}
+
+					if(posting_datetime < from_date) {
+						item.opening += diff;
+					} else if(posting_datetime <= to_date) {
+						item[me.column_map[sl.posting_date].field] += diff;
+					} else {
+						break;
+					}
+
+					item.closing_qty_value += diff;
+				}
+			}
+		},
+		update_groups: function() {
+			var me = this;
+			$.each(this.data, function(i, item) {
+				// update groups
+				if(!item.is_group && me.apply_filter(item, "brand")) {
+					var balance = item.opening;
+					$.each(me.columns, function(i, col) {
+						if(col.formatter==me.currency_formatter && !col.hidden) {
+							item[col.field] = balance + item[col.field];
+							balance = item[col.field];
 						}
 					});
-					parent = me.parent_map[parent];
+
+					var parent = me.parent_map[item.name];
+					while(parent) {
+						parent_group = me.item_by_name[parent];
+						$.each(me.columns, function(c, col) {
+							if (col.formatter == me.currency_formatter) {
+								parent_group[col.field] =
+									flt(parent_group[col.field])
+									+ flt(item[col.field]);
+							}
+						});
+						parent = me.parent_map[parent];
+					}
 				}
-			}
-		});
-	},
-	get_plot_points: function(item, col, idx) {
-		return [[dateutil.user_to_obj(col.name).getTime(), item[col.field]]]
-	},
-	show_stock_ledger: function(item_code) {
-		frappe.route_options = {
-			item_code: item_code,
-			from_date: this.from_date,
-			to_date: this.to_date
-		};
-		frappe.set_route("query-report", "Stock Ledger");
-	}
+			});
+		},
+		get_plot_points: function(item, col, idx) {
+			return [[dateutil.user_to_obj(col.name).getTime(), item[col.field]]]
+		},
+		show_stock_ledger: function(item_code) {
+			frappe.route_options = {
+				item_code: item_code,
+				from_date: this.from_date,
+				to_date: this.to_date
+			};
+			frappe.set_route("query-report", "Stock Ledger");
+		}
+	});
 });
+
diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js
index f0e1eab..09deea2 100644
--- a/erpnext/selling/doctype/installation_note/installation_note.js
+++ b/erpnext/selling/doctype/installation_note/installation_note.js
@@ -1,7 +1,7 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/utils.js");
+
 
 frappe.ui.form.on_change("Installation Note", "customer",
 	function(frm) { erpnext.utils.get_party_details(frm); });
diff --git a/erpnext/selling/report/quotation_trends/quotation_trends.js b/erpnext/selling/report/quotation_trends/quotation_trends.js
index ba62bf1..294aea0 100644
--- a/erpnext/selling/report/quotation_trends/quotation_trends.js
+++ b/erpnext/selling/report/quotation_trends/quotation_trends.js
@@ -1,8 +1,9 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/sales_trends_filters.js");
+frappe.require("assets/erpnext/js/sales_trends_filters.js", function() {
+	frappe.query_reports["Quotation Trends"] = {
+		filters: get_filters()
+	}
+});
 
-frappe.query_reports["Quotation Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
diff --git a/erpnext/selling/report/sales_order_trends/sales_order_trends.js b/erpnext/selling/report/sales_order_trends/sales_order_trends.js
index cee6004..863afb8 100644
--- a/erpnext/selling/report/sales_order_trends/sales_order_trends.js
+++ b/erpnext/selling/report/sales_order_trends/sales_order_trends.js
@@ -1,8 +1,8 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/sales_trends_filters.js");
-
-frappe.query_reports["Sales Order Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
+frappe.require("assets/erpnext/js/sales_trends_filters.js", function() {
+	frappe.query_reports["Sales Order Trends"] = {
+		filters: get_filters()
+	}
+});
\ No newline at end of file
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 167024b..5906a4f 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -5,11 +5,10 @@
 cur_frm.cscript.tax_table = "Sales Taxes and Charges";
 {% include 'erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js' %}
 
-frappe.provide("erpnext.selling");
-frappe.require("assets/erpnext/js/controllers/transaction.js");
 
 cur_frm.email_field = "contact_email";
 
+frappe.provide("erpnext.selling");
 erpnext.selling.SellingController = erpnext.TransactionController.extend({
 	onload: function() {
 		this._super();
@@ -182,7 +181,7 @@
 	warehouse: function(doc, cdt, cdn) {
 		var me = this;
 		var item = frappe.get_doc(cdt, cdn);
-		
+
 		if(item.item_code && item.warehouse) {
 			return this.frm.call({
 				method: "erpnext.stock.get_item_details.get_bin_details",
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 6765a3c..7f2be4f 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -2,7 +2,6 @@
 // License: GNU General Public License v3. See license.txt
 
 frappe.provide("erpnext.item");
-frappe.require('assets/js/item-dashboard.min.js');
 
 frappe.ui.form.on("Item", {
 	onload: function(frm) {
@@ -77,17 +76,6 @@
 
 		erpnext.item.toggle_attributes(frm);
 
-		frm.dashboard.show_heatmap = frm.doc.is_stock_item;
-		frm.dashboard.heatmap_message = __('This is based on stock movement. See {0} for details',
-			['<a href="#query-report/Stock Ledger">' + __('Stock Ledger') + '</a>']);
-		frm.dashboard.show_dashboard();
-
-		var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;">Stock Levels</h5>');
-		erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({
-			parent: section,
-			item_code: frm.doc.name
-		});
-		erpnext.item.item_dashboard.refresh();
 
 	},
 
@@ -184,6 +172,20 @@
 		frm.dashboard.reset();
 		if(frm.doc.__islocal)
 			return;
+
+		frm.dashboard.show_heatmap = frm.doc.is_stock_item;
+		frm.dashboard.heatmap_message = __('This is based on stock movement. See {0} for details',
+			['<a href="#query-report/Stock Ledger">' + __('Stock Ledger') + '</a>']);
+		frm.dashboard.show_dashboard();
+
+		frappe.require('assets/js/item-dashboard.min.js', function() {
+			var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;">Stock Levels</h5>');
+			erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({
+				parent: section,
+				item_code: frm.doc.name
+			});
+			erpnext.item.item_dashboard.refresh();
+		});
 	},
 
 	edit_prices_button: function(frm) {
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
index 5a86c89..15a5759 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.js
@@ -3,7 +3,6 @@
 
 
 frappe.provide("erpnext.stock");
-frappe.require("assets/erpnext/js/controllers/stock_controller.js");
 
 erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
 	setup: function() {
@@ -11,16 +10,16 @@
 		this.frm.fields_dict.purchase_receipts.grid.get_field('receipt_document').get_query =
 			function(doc, cdt ,cdn) {
 				var d = locals[cdt][cdn]
-				
+
 				var filters = [
 					[d.receipt_document_type, 'docstatus', '=', '1'],
 					[d.receipt_document_type, 'company', '=', me.frm.doc.company],
 				]
-				
+
 				if(d.receipt_document_type == "Purchase Invoice") {
 					filters.push(["Purchase Invoice", "update_stock", "=", "1"])
 				}
-								
+
 				if(!me.frm.doc.company) msgprint(__("Please enter company first"));
 				return {
 					filters:filters
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index a4bae78..1dcbcb7 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -3,7 +3,7 @@
 
 {% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
 
-frappe.require("assets/erpnext/js/utils.js");
+
 
 frappe.ui.form.on("Material Request Item", {
 	"qty": function(frm, doctype, name) {
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 1696b02..76b0395 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -1,10 +1,5 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt
 
-frappe.require([
-	"assets/erpnext/js/controllers/stock_controller.js",
-	"assets/erpnext/js/utils.js",
-	"assets/erpnext/js/utils/item_selector.js"]);
-
 frappe.provide("erpnext.stock");
 
 erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index f5f4e03..ead110c 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -1,8 +1,6 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/controllers/stock_controller.js");
-frappe.require("assets/erpnext/js/utils.js");
 frappe.provide("erpnext.stock");
 
 frappe.ui.form.on("Stock Reconciliation", {
diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.js b/erpnext/stock/page/stock_analytics/stock_analytics.js
index bd2d9f6..f86201f 100644
--- a/erpnext/stock/page/stock_analytics/stock_analytics.js
+++ b/erpnext/stock/page/stock_analytics/stock_analytics.js
@@ -1,19 +1,16 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
+frappe.require("assets/erpnext/js/stock_analytics.js", function() {
+	frappe.pages['stock-analytics'].on_page_load = function(wrapper) {
+		frappe.ui.make_app_page({
+			parent: wrapper,
+			title: __('Stock Analytics'),
+			single_column: true
+		});
 
-frappe.pages['stock-analytics'].on_page_load = function(wrapper) {
-	frappe.ui.make_app_page({
-		parent: wrapper,
-		title: __('Stock Analytics'),
-		single_column: true
-	});
+		new erpnext.StockAnalytics(wrapper);
 
-	new erpnext.StockAnalytics(wrapper);
-
-
-	frappe.breadcrumbs.add("Stock")
-
-};
-
-frappe.require("assets/erpnext/js/stock_analytics.js");
+		frappe.breadcrumbs.add("Stock")
+	};
+});
diff --git a/erpnext/stock/page/stock_balance/stock_balance.js b/erpnext/stock/page/stock_balance/stock_balance.js
index 7bf4792..2b6fd8d 100644
--- a/erpnext/stock/page/stock_balance/stock_balance.js
+++ b/erpnext/stock/page/stock_balance/stock_balance.js
@@ -1,5 +1,3 @@
-frappe.require('assets/js/item-dashboard.min.js');
-
 frappe.pages['stock-balance'].on_page_load = function(wrapper) {
 	var page = frappe.ui.make_app_page({
 		parent: wrapper,
@@ -52,32 +50,35 @@
 
 	page.sort_selector.wrapper.css({'margin-right': '15px', 'margin-top': '4px'});
 
-	page.item_dashboard = new erpnext.stock.ItemDashboard({
-		parent: page.main,
-	})
+	frappe.require('assets/js/item-dashboard.min.js', function() {
+		page.item_dashboard = new erpnext.stock.ItemDashboard({
+			parent: page.main,
+		})
 
-	page.item_dashboard.before_refresh = function() {
-		this.item_code = page.item_field.get_value();
-		this.warehouse = page.warehouse_field.get_value();
-	}
+		page.item_dashboard.before_refresh = function() {
+			this.item_code = page.item_field.get_value();
+			this.warehouse = page.warehouse_field.get_value();
+		}
 
-	page.item_dashboard.refresh();
+		page.item_dashboard.refresh();
 
-	// item click
-	var setup_click = function(doctype) {
-		page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() {
-			var name = $(this).attr('data-name');
-			var field = page[doctype.toLowerCase() + '_field'];
-			if(field.get_value()===name) {
-				frappe.set_route('Form', doctype, name)
-			} else {
-				field.set_input(name);
-				page.item_dashboard.refresh();
-			}
-		});
-	}
+		// item click
+		var setup_click = function(doctype) {
+			page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() {
+				var name = $(this).attr('data-name');
+				var field = page[doctype.toLowerCase() + '_field'];
+				if(field.get_value()===name) {
+					frappe.set_route('Form', doctype, name)
+				} else {
+					field.set_input(name);
+					page.item_dashboard.refresh();
+				}
+			});
+		}
 
-	setup_click('Item');
-	setup_click('Warehouse');
+		setup_click('Item');
+		setup_click('Warehouse');
+	});
+
 
 }
\ No newline at end of file
diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js
index 45955fb..0e12907 100644
--- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js
+++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.js
@@ -1,8 +1,9 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/sales_trends_filters.js");
+frappe.require("assets/erpnext/js/sales_trends_filters.js", function() {
+	frappe.query_reports["Delivery Note Trends"] = {
+		filters: get_filters()
+	}
+});
 
-frappe.query_reports["Delivery Note Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js
index 19a58ef..d94b49e 100644
--- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js
+++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.js
@@ -1,8 +1,9 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.require("assets/erpnext/js/purchase_trends_filters.js");
+frappe.require("assets/erpnext/js/purchase_trends_filters.js", function() {
+	frappe.query_reports["Purchase Receipt Trends"] = {
+		filters: get_filters()
+	}
+});
 
-frappe.query_reports["Purchase Receipt Trends"] = {
-	filters: get_filters()
- }
\ No newline at end of file
diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
index b37c47b..a267eb3 100644
--- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
+++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
@@ -2,7 +2,7 @@
 // License: GNU General Public License v3. See license.txt
 
 frappe.provide("erpnext.support");
-frappe.require("assets/erpnext/js/utils.js");
+
 
 frappe.ui.form.on_change("Maintenance Visit", "customer", function(frm) {
 	erpnext.utils.get_party_details(frm) });
diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js
index 3928577..0511ff6 100644
--- a/erpnext/support/doctype/warranty_claim/warranty_claim.js
+++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js
@@ -2,7 +2,8 @@
 // License: GNU General Public License v3. See license.txt
 
 frappe.provide("erpnext.support");
-frappe.require("assets/erpnext/js/utils.js");
+
+{% include "erpnext/public/js/utils.js" %}
 
 frappe.ui.form.on("Warranty Claim", {
 	customer: function(frm) {
diff --git a/erpnext/templates/form_grid/item_grid.html b/erpnext/templates/form_grid/item_grid.html
index 1c50e15..c596890 100644
--- a/erpnext/templates/form_grid/item_grid.html
+++ b/erpnext/templates/form_grid/item_grid.html
@@ -13,7 +13,7 @@
 	<div class="row">
 		<div class="col-sm-6 col-xs-8">
 			{% if(doc.warehouse) {
-				var label_class = "label-default",
+				var color = "grey",
 					title = "Warehouse",
 					actual_qty = (frm.doc.doctype==="Sales Order"
 						? doc.projected_qty : doc.actual_qty);
@@ -21,16 +21,16 @@
                     && in_list(["Sales Order Item", "Delivery Note Item"], doc.doctype)) {
     				if(actual_qty != undefined) {
     					if(actual_qty >= doc.qty) {
-    						var label_class = "label-success";
+    						var color = "green";
     						var title = "In Stock"
     					} else {
-    						var label_class = "label-danger";
+    						var color = "red";
     						var title = "Not In Stock"
     					}
     				}
                 } %}
-				<span class="pull-right" title="{%= title %}">
-					<span class="label {%= label_class %}">
+				<span class="pull-right" title="{%= title %}" style="margin-left: 10px;">
+					<span class="indicator {{ color }}">
 						{%= doc.warehouse %}
 					</span>
 				</span>
diff --git a/erpnext/templates/form_grid/stock_entry_grid.html b/erpnext/templates/form_grid/stock_entry_grid.html
index a2bf1df..8604881 100644
--- a/erpnext/templates/form_grid/stock_entry_grid.html
+++ b/erpnext/templates/form_grid/stock_entry_grid.html
@@ -16,21 +16,27 @@
 			{% if(doc.item_name != doc.item_code) { %}
 				<br>{%= doc.item_name %}{% } %}
 			{% include "templates/form_grid/includes/visible_cols.html" %}
-			{% if(frm.doc.docstatus==0 && doc.s_warehouse && doc.actual_qty < doc.qty) { %}
-                <span class="text-danger small" style="margin-left: 15px;">
-                    Not in Stock
-                </span>
-            {% } %}
 		</div>
 
         <!-- warehouse -->
 		<div class="col-sm-3 col-xs-4">
-			{% if(doc.s_warehouse) { %}
-                <span class="label label-default grid-label" title="{% __("Source" )%}">
-				{%= doc.s_warehouse || "" %}</span>
-            {% } %}
-			{% if(doc.t_warehouse) { %}<span class="label label-primary grid-label" title="{% __("Target" )%}">
-				{%= doc.t_warehouse || "" %}</span>{% } %}
+			{% if(doc.s_warehouse) {
+					if(frm.doc.docstatus==0) {
+						var color = (doc.s_warehouse && doc.actual_qty < doc.qty) ? "red" : "green";
+						var title = color === "red" ? __("Not in Stock") : __("In Stock");
+					} else {
+						var color = "grey";
+						var title = __("Source");
+					}
+				%}
+				 <span class="indicator {{ color }}" title="{{ title }}">
+					 {%= doc.s_warehouse %}</span>
+            {% }; %}
+			{% if(doc.t_warehouse) { %}
+				<div><span class="indicator {{ doc.docstatus==1 ? "blue" : "grey" }}" title="{{ __("Target" ) }}">
+					{%= doc.t_warehouse %}</span>
+				</div>
+            {% }; %}
 		</div>
 
 		<!-- qty -->