[enhancement] [minor] stock ledger, general ledger buttons in warehouse
diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js
index 22396b7..586d248 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.js
+++ b/erpnext/stock/doctype/warehouse/warehouse.js
@@ -1,9 +1,25 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-cur_frm.cscript.refresh = function(doc) {
- cur_frm.toggle_display('warehouse_name', doc.__islocal);
-}
+frappe.ui.form.on("Warehouse", {
+ refresh: function(frm) {
+ frm.toggle_display('warehouse_name', frm.doc.__islocal);
+
+ frm.add_custom_button(__("Stock Ledger"), function() {
+ frappe.set_route("query-report", "Stock Ledger", {"warehouse": frm.doc.name});
+ });
+ if(frm.doc.__onload && frm.doc.__onload.account) {
+ frm.add_custom_button(__("General Ledger"), function() {
+ frappe.route_options = {
+ "account": frm.doc.__onload.account,
+ "company": frm.doc.company
+ }
+ frappe.set_route("query-report", "General Ledger");
+ });
+ }
+ }
+});
+
cur_frm.set_query("create_account_under", function() {
return {
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 610c7b8..901b229 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -14,6 +14,14 @@
if not self.warehouse_name.endswith(suffix):
self.name = self.warehouse_name + suffix
+ def onload(self):
+ '''load account name for General Ledger Report'''
+ account = frappe.db.get_value("Account", {
+ "account_type": "Warehouse", "company": self.company, "warehouse": self.name})
+
+ if account:
+ self.set_onload('account', account)
+
def validate(self):
if self.email_id:
validate_email_add(self.email_id, True)