Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js
index 2d35bd1..8535373 100644
--- a/accounts/doctype/account/account.js
+++ b/accounts/doctype/account/account.js
@@ -20,13 +20,6 @@
 cur_frm.cscript.onload = function(doc, cdt, cdn) {
 }
 
-cur_frm.cscript.set_breadcrumbs = function(barea) {
-	cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname);
-	cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!Accounts Browser/Account">\
-		Chart of Accounts</a>');
-	cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!accounts-home">Accounts</a>');
-}
-
 // Refresh
 // -----------------------------------------
 cur_frm.cscript.refresh = function(doc, cdt, cdn) {
@@ -55,7 +48,7 @@
 		cur_frm.cscript.account_type(doc, cdt, cdn);
 
 		// show / hide convert buttons
-		cur_frm.cscript.hide_unhide_group_ledger(doc);		
+		cur_frm.cscript.hide_unhide_group_ledger(doc);
 	}
 }
 
@@ -90,6 +83,10 @@
 	} else if (cstr(doc.group_or_ledger) == 'Ledger') {
 		cur_frm.add_custom_button('Convert to Group', 
 			function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
+			
+		cur_frm.add_custom_button('View Ledger', function() {
+			wn.set_route("general-ledger", "account=" + doc.name);
+		});
 	}
 }
 // Convert group to ledger
diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js
index d60dba6..410643d 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/accounts/doctype/journal_voucher/journal_voucher.js
@@ -74,6 +74,25 @@
 	return "SELECT `tabSales Invoice`.name, `tabSales Invoice`.debit_to, `tabSales Invoice`.outstanding_amount FROM `tabSales Invoice` WHERE `tabSales Invoice`.debit_to='"+d.account+"' AND `tabSales Invoice`.outstanding_amount > 0 AND `tabSales Invoice`.docstatus = 1 AND `tabSales Invoice`.%(key)s LIKE '%s' ORDER BY `tabSales Invoice`.name DESC LIMIT 200";
 }
 
+cur_frm.fields_dict['entries'].grid.get_field('against_jv').get_query = function(doc) {
+	var d = locals[this.doctype][this.docname];
+	
+	if(!d.account) {
+		msgprint("Please select Account first!")
+		throw "account not selected"
+	}
+	
+	return "SELECT `tabJournal Voucher`.name, `tabJournal Voucher`.posting_date,\
+		`tabJournal Voucher`.user_remark\
+		from `tabJournal Voucher`, `tabJournal Voucher Detail`\
+		where `tabJournal Voucher Detail`.account = '"+ esc_quotes(d.account) + "'\
+		and `tabJournal Voucher`.name like '%s'\
+		and `tabJournal Voucher`.docstatus=1\
+		and `tabJournal Voucher`.voucher_type='Journal Entry'\
+		and `tabJournal Voucher Detail`.parent = `tabJournal Voucher`.name";
+}
+
+
 // TDS Account Head
 cur_frm.fields_dict['tax_code'].get_query = function(doc) {
 	return "SELECT `tabTDS Category Account`.account_head FROM `tabTDS Category Account` WHERE `tabTDS Category Account`.parent = '"+doc.tds_category+"' AND `tabTDS Category Account`.company='"+doc.company+"' AND `tabTDS Category Account`.account_head LIKE '%s' ORDER BY `tabTDS Category Account`.account_head DESC LIMIT 50";
diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py
index c750fc3..d6dcdf2 100644
--- a/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/accounts/doctype/journal_voucher/journal_voucher.py
@@ -149,16 +149,16 @@
 	def validate_cheque_info(self):
 		if self.doc.voucher_type in ['Bank Voucher']:
 			if not self.doc.cheque_no or not self.doc.cheque_date:
-				msgprint("Cheque No & Cheque Date is required for " + cstr(self.doc.voucher_type))
+				msgprint("Reference No & Reference Date is required for " + cstr(self.doc.voucher_type))
 				raise Exception
 				
 		if self.doc.cheque_date and not self.doc.cheque_no:
-			msgprint("Cheque No is mandatory if you entered Cheque Date")
+			msgprint("Reference No is mandatory if you entered Reference Date")
 			raise Exception
 			
 	def validate_entries_for_advance(self):
 		for d in getlist(self.doclist,'entries'):
-			if not d.is_advance and not d.against_voucher and not d.against_invoice and d.against_jv:
+			if not d.is_advance and not d.against_voucher and not d.against_invoice and not d.against_jv:
 				master_type = self.get_master_type(d.account)
 				if (master_type == 'Customer' and flt(d.credit) > 0) or (master_type == 'Supplier' and flt(d.debit) > 0):
 					msgprint("Message: Please check Is Advance as 'Yes' against Account %s if this is an advance entry." % d.account)
diff --git a/accounts/page/financial_analytics/financial_analytics.js b/accounts/page/financial_analytics/financial_analytics.js
index 3d8dec7..264ced3 100644
--- a/accounts/page/financial_analytics/financial_analytics.js
+++ b/accounts/page/financial_analytics/financial_analytics.js
@@ -14,7 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.	If not, see <http://www.gnu.org/licenses/>.
 
-wn.require("lib/js/wn/views/grid_report.js");
 wn.require("app/js/account_tree_grid.js");
 
 wn.pages['financial-analytics'].onload = function(wrapper) { 
diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js
index b7645ec..8e70619 100644
--- a/accounts/page/general_ledger/general_ledger.js
+++ b/accounts/page/general_ledger/general_ledger.js
@@ -25,8 +25,6 @@
 
 }
 
-wn.require("lib/js/wn/views/grid_report.js");
-
 erpnext.GeneralLedger = wn.views.GridReport.extend({
 	init: function(wrapper) {
 		this._super({
@@ -45,6 +43,7 @@
 				link_formatter: {
 					filter_input: "account",
 					open_btn: true,
+					doctype: "'Account'"
 				}},
 			{id: "debit", name: "Debit", field: "debit", width: 100,
 				formatter: this.currency_formatter},
diff --git a/accounts/page/trial_balance/trial_balance.js b/accounts/page/trial_balance/trial_balance.js
index 3ecfba7..3504ae0 100644
--- a/accounts/page/trial_balance/trial_balance.js
+++ b/accounts/page/trial_balance/trial_balance.js
@@ -14,7 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.	If not, see <http://www.gnu.org/licenses/>.
 
-wn.require("lib/js/wn/views/grid_report.js");
 wn.require("app/js/account_tree_grid.js");
 
 wn.pages['trial-balance'].onload = function(wrapper) { 
diff --git a/buying/page/purchase_analytics/purchase_analytics.js b/buying/page/purchase_analytics/purchase_analytics.js
index 556eb72..ac0e41f 100644
--- a/buying/page/purchase_analytics/purchase_analytics.js
+++ b/buying/page/purchase_analytics/purchase_analytics.js
@@ -23,7 +23,6 @@
 	
 	new erpnext.PurchaseAnalytics(wrapper);
 }
-wn.require("lib/js/wn/views/grid_report.js");
 
 erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
 	init: function(wrapper) {
diff --git a/selling/page/sales_analytics/sales_analytics.js b/selling/page/sales_analytics/sales_analytics.js
index 17246de..b87ead5 100644
--- a/selling/page/sales_analytics/sales_analytics.js
+++ b/selling/page/sales_analytics/sales_analytics.js
@@ -23,8 +23,6 @@
 	new erpnext.SalesAnalytics(wrapper);
 }
 
-wn.require("lib/js/wn/views/grid_report.js");
-
 erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({
 	init: function(wrapper) {
 		this._super({
diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js
index 3418e7f..7e9b84f 100644
--- a/stock/page/stock_ageing/stock_ageing.js
+++ b/stock/page/stock_ageing/stock_ageing.js
@@ -26,7 +26,6 @@
 	
 }
 
-wn.require("lib/js/wn/views/grid_report.js");
 wn.require("app/js/stock_grid_report.js");
 
 erpnext.StockAgeing = erpnext.StockGridReport.extend({
diff --git a/stock/page/stock_analytics/stock_analytics.js b/stock/page/stock_analytics/stock_analytics.js
index bec0bc2..9b0309f 100644
--- a/stock/page/stock_analytics/stock_analytics.js
+++ b/stock/page/stock_analytics/stock_analytics.js
@@ -24,7 +24,6 @@
 	new erpnext.StockAnalytics(wrapper);
 }
 
-wn.require("lib/js/wn/views/grid_report.js");
 wn.require("app/js/stock_grid_report.js");
 
 erpnext.StockAnalytics = erpnext.StockGridReport.extend({
diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js
index 67c82dd..2b8fa9e 100644
--- a/stock/page/stock_ledger/stock_ledger.js
+++ b/stock/page/stock_ledger/stock_ledger.js
@@ -24,7 +24,6 @@
 	new erpnext.StockLedger(wrapper);
 }
 
-wn.require("lib/js/wn/views/grid_report.js");
 wn.require("app/js/stock_grid_report.js");
 
 erpnext.StockLedger = erpnext.StockGridReport.extend({