[fix] tree view hooks and patch fix

This commit is contained in:
Rushabh Mehta 2016-06-25 18:30:03 +05:30
parent 8942d1782c
commit 723cd64249
9 changed files with 18 additions and 21 deletions

View File

@ -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) {

View File

@ -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:
@ -181,9 +181,10 @@ class Account(Document):
def validate_warehouse(self, warehouse):
lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"])
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 Warehouse").format(warehouse))
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"""

View File

@ -3,7 +3,6 @@
frappe.provide("erpnext.accounts");
cur_frm.list_route = "Tree/Cost Center";
frappe.ui.form.on('Cost Center', {

View File

@ -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"

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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",