Allow user to change page_name in Item and Item Group #2397

This commit is contained in:
Anand Doshi
2015-02-25 13:50:14 +05:30
parent 28d21ba3c0
commit d75ef108fc
3 changed files with 214 additions and 201 deletions

View File

@@ -1,30 +1,36 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.list_route = "Sales Browser/Item Group";
frappe.ui.form.on("Item Group", {
onload: function(frm) {
frm.list_route = "Sales Browser/Item Group";
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc);
cur_frm.add_custom_button(__("Item Group Tree"), function() {
frappe.set_route("Sales Browser", "Item Group");
}, "icon-sitemap")
}
//get query select item group
frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
return{
filters:[
['Item Group', 'is_group', '=', 'Yes'],
['Item Group', 'name', '!=', doc.item_group_name]
]
}
}
},
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root item group
cur_frm.set_intro("");
if(!doc.parent_item_group) {
cur_frm.set_read_only();
cur_frm.set_intro(__("This is a root item group and cannot be edited."), true);
}
}
refresh: function(frm) {
frm.trigger("set_root_readonly");
frm.add_custom_button(__("Item Group Tree"), function() {
frappe.set_route("Sales Browser", "Item Group");
}, "icon-sitemap");
},
//get query select item group
cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
return{
filters:[
['Item Group', 'is_group', '=', 'Yes'],
['Item Group', 'name', '!=', doc.item_group_name]
]
}
}
set_root_readonly: function(frm) {
// read-only for root item group
frm.set_intro("");
if(!frm.doc.parent_item_group) {
frm.set_read_only();
frm.set_intro(__("This is a root item group and cannot be edited."), true);
}
},
page_name: frappe.utils.warn_page_name_change
});