[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 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
cur_frm.list_route = "Tree/Account";
cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.__islocal) { if(doc.__islocal) {

View File

@ -169,8 +169,8 @@ class Account(Document):
if not self.warehouse: if not self.warehouse:
throw(_("Warehouse is mandatory if account type is Warehouse")) throw(_("Warehouse is mandatory if account type is Warehouse"))
old_warehouse = cstr(frappe.db.get_value("Account", self.name, "warehouse")) old_warehouse = frappe.db.get_value("Account", self.name, "warehouse")
if old_warehouse != cstr(self.warehouse): if old_warehouse != self.warehouse:
if old_warehouse: if old_warehouse:
self.validate_warehouse(old_warehouse) self.validate_warehouse(old_warehouse)
if self.warehouse: if self.warehouse:
@ -181,9 +181,10 @@ class Account(Document):
def validate_warehouse(self, warehouse): def validate_warehouse(self, warehouse):
lft, rgt = frappe.db.get_value("Warehouse", warehouse, ["lft", "rgt"]) 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 if lft and rgt:
tabWarehouse wh where lft >= %s and rgt <= %s and sle.warehouse = wh.name)""", (lft, rgt)): if frappe.db.sql_list("""select sle.name from `tabStock Ledger Entry` sle where exists (select wh.name from
throw(_("Stock entries exist against warehouse {0}, hence you cannot re-assign or modify Warehouse").format(warehouse)) 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): def update_nsm_model(self):
"""update lft, rgt indices for nested set model""" """update lft, rgt indices for nested set model"""

View File

@ -3,7 +3,6 @@
frappe.provide("erpnext.accounts"); frappe.provide("erpnext.accounts");
cur_frm.list_route = "Tree/Cost Center";
frappe.ui.form.on('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" on_logout = "erpnext.shopping_cart.utils.clear_cart_count"
remember_selected = ['Company', 'Cost Center', 'Project'] remember_selected = ['Company', 'Cost Center', 'Project']
treeviews = ['Account', 'Cost Center', 'Warehouse', 'Item Group', 'Customer Group', 'Sales Person', 'Territory']
# website # website
update_website_context = "erpnext.shopping_cart.utils.update_website_context" 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 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // 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.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc); cur_frm.cscript.set_root_readonly(doc);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // 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.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc); cur_frm.cscript.set_root_readonly(doc);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // 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.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc); cur_frm.cscript.set_root_readonly(doc);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
cur_frm.list_route = "Tree/Warehouse";
frappe.ui.form.on("Warehouse", { frappe.ui.form.on("Warehouse", {
refresh: function(frm) { refresh: function(frm) {

View File

@ -425,7 +425,7 @@
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 1,
"fieldname": "tree_details", "fieldname": "tree_details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -505,7 +505,7 @@
"collapsible": 0, "collapsible": 0,
"fieldname": "lft", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 0, "hidden": 1,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
@ -517,7 +517,7 @@
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 1,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -530,7 +530,7 @@
"collapsible": 0, "collapsible": 0,
"fieldname": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 0, "hidden": 1,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
@ -542,7 +542,7 @@
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 1,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -555,7 +555,7 @@
"collapsible": 0, "collapsible": 0,
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 1,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
@ -568,7 +568,7 @@
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 1,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -580,13 +580,14 @@
"hide_toolbar": 0, "hide_toolbar": 0,
"icon": "icon-building", "icon": "icon-building",
"idx": 1, "idx": 1,
"image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0, "in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-05-23 21:25:21.396188", "modified": "2016-06-25 18:21:05.175172",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Warehouse", "name": "Warehouse",