From 723cd6424910f7b65f7e006b95ff11525fe391dd Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 25 Jun 2016 18:30:03 +0530 Subject: [PATCH] [fix] tree view hooks and patch fix --- erpnext/accounts/doctype/account/account.js | 1 - erpnext/accounts/doctype/account/account.py | 15 ++++++++------- .../accounts/doctype/cost_center/cost_center.js | 1 - erpnext/hooks.py | 1 + .../doctype/customer_group/customer_group.js | 1 - .../setup/doctype/sales_person/sales_person.js | 1 - erpnext/setup/doctype/territory/territory.js | 1 - erpnext/stock/doctype/warehouse/warehouse.js | 1 - erpnext/stock/doctype/warehouse/warehouse.json | 17 +++++++++-------- 9 files changed, 18 insertions(+), 21 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 44c2ca45fbc..b2eef20a458 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -1,7 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.list_route = "Tree/Account"; cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.__islocal) { diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 918917c56a4..83517ce717d 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -169,8 +169,8 @@ class Account(Document): if not self.warehouse: throw(_("Warehouse is mandatory if account type is Warehouse")) - old_warehouse = cstr(frappe.db.get_value("Account", self.name, "warehouse")) - if old_warehouse != cstr(self.warehouse): + old_warehouse = frappe.db.get_value("Account", self.name, "warehouse") + if old_warehouse != self.warehouse: if old_warehouse: self.validate_warehouse(old_warehouse) if self.warehouse: @@ -180,11 +180,12 @@ class Account(Document): def validate_warehouse(self, warehouse): lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"]) - - if frappe.db.sql_list("""select sle.name from `tabStock Ledger Entry` sle where exists (select wh.name from - tabWarehouse wh where lft >= %s and rgt <= %s and sle.warehouse = wh.name)""", (lft, rgt)): - throw(_("Stock entries exist against warehouse {0}, hence you cannot re-assign or modify Warehouse").format(warehouse)) - + + if lft and rgt: + if frappe.db.sql_list("""select sle.name from `tabStock Ledger Entry` sle where exists (select wh.name from + tabWarehouse wh where lft >= %s and rgt <= %s and sle.warehouse = wh.name)""", (lft, rgt)): + throw(_("Stock entries exist against Warehouse {0}, hence you cannot re-assign or modify it").format(warehouse)) + def update_nsm_model(self): """update lft, rgt indices for nested set model""" import frappe diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index a5419016e61..dea87f3f464 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -3,7 +3,6 @@ frappe.provide("erpnext.accounts"); -cur_frm.list_route = "Tree/Cost Center"; frappe.ui.form.on('Cost Center', { diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 0c8de2a1866..5b648c6e603 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -33,6 +33,7 @@ on_session_creation = "erpnext.shopping_cart.utils.set_cart_count" on_logout = "erpnext.shopping_cart.utils.clear_cart_count" remember_selected = ['Company', 'Cost Center', 'Project'] +treeviews = ['Account', 'Cost Center', 'Warehouse', 'Item Group', 'Customer Group', 'Sales Person', 'Territory'] # website update_website_context = "erpnext.shopping_cart.utils.update_website_context" diff --git a/erpnext/setup/doctype/customer_group/customer_group.js b/erpnext/setup/doctype/customer_group/customer_group.js index 3dc5c6c6077..654abd90a5c 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.js +++ b/erpnext/setup/doctype/customer_group/customer_group.js @@ -1,7 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.list_route = "Tree/Customer Group"; cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly(doc); diff --git a/erpnext/setup/doctype/sales_person/sales_person.js b/erpnext/setup/doctype/sales_person/sales_person.js index 13683924890..2ee3974a225 100644 --- a/erpnext/setup/doctype/sales_person/sales_person.js +++ b/erpnext/setup/doctype/sales_person/sales_person.js @@ -1,7 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.list_route = "Tree/Sales Person"; cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly(doc); diff --git a/erpnext/setup/doctype/territory/territory.js b/erpnext/setup/doctype/territory/territory.js index bf4e29b1054..317278aad81 100644 --- a/erpnext/setup/doctype/territory/territory.js +++ b/erpnext/setup/doctype/territory/territory.js @@ -1,7 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.list_route = "Tree/Territory"; cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly(doc); diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index 4a84eadb998..b7a3a34c6d2 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -1,7 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.list_route = "Tree/Warehouse"; frappe.ui.form.on("Warehouse", { refresh: function(frm) { diff --git a/erpnext/stock/doctype/warehouse/warehouse.json b/erpnext/stock/doctype/warehouse/warehouse.json index 6b60c635d48..1a3a97f1ff9 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.json +++ b/erpnext/stock/doctype/warehouse/warehouse.json @@ -425,7 +425,7 @@ { "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "fieldname": "tree_details", "fieldtype": "Section Break", "hidden": 0, @@ -505,7 +505,7 @@ "collapsible": 0, "fieldname": "lft", "fieldtype": "Int", - "hidden": 0, + "hidden": 1, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, @@ -517,7 +517,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -530,7 +530,7 @@ "collapsible": 0, "fieldname": "rgt", "fieldtype": "Int", - "hidden": 0, + "hidden": 1, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, @@ -542,7 +542,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -555,7 +555,7 @@ "collapsible": 0, "fieldname": "old_parent", "fieldtype": "Link", - "hidden": 0, + "hidden": 1, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, @@ -568,7 +568,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -580,13 +580,14 @@ "hide_toolbar": 0, "icon": "icon-building", "idx": 1, + "image_view": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-05-23 21:25:21.396188", + "modified": "2016-06-25 18:21:05.175172", "modified_by": "Administrator", "module": "Stock", "name": "Warehouse",