fix: show new button in coa if create access

(cherry picked from commit 3125bc8a16)
This commit is contained in:
sokumon
2025-01-06 12:26:06 +05:30
committed by Mergify
parent 2333d33362
commit 89155f529e

View File

@@ -237,19 +237,22 @@ frappe.treeview_settings["Account"] = {
}, },
post_render: function (treeview) { post_render: function (treeview) {
frappe.treeview_settings["Account"].treeview["tree"] = treeview.tree; frappe.treeview_settings["Account"].treeview["tree"] = treeview.tree;
if (treeview.can_create) {
treeview.page.set_primary_action( treeview.page.set_primary_action(
__("New"), __("New"),
function () { function () {
let root_company = treeview.page.fields_dict.root_company.get_value(); let root_company = treeview.page.fields_dict.root_company.get_value();
if (root_company) { if (root_company) {
frappe.throw(__("Please add the account to root level Company - {0}"), [root_company]); frappe.throw(__("Please add the account to root level Company - {0}"), [
root_company,
]);
} else { } else {
treeview.new_node(); treeview.new_node();
} }
}, },
"add" "add"
); );
}
}, },
toolbar: [ toolbar: [
{ {