refactor: show form buttons only if permissions exist (#23851)
* refactor: show form buttons only if permissions exist * style: add semicolon * fix: typo in conditions
This commit is contained in:
parent
8cfb210dc4
commit
f38a1c305e
@ -90,30 +90,42 @@ frappe.ui.form.on("Company", {
|
||||
frm.toggle_enable("default_currency", (frm.doc.__onload &&
|
||||
!frm.doc.__onload.transactions_exist));
|
||||
|
||||
if (frm.has_perm('write')) {
|
||||
frm.add_custom_button(__('Create Tax Template'), function() {
|
||||
frm.trigger("make_default_tax_template");
|
||||
});
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Cost Center", 0, 'read')) {
|
||||
frm.add_custom_button(__('Cost Centers'), function() {
|
||||
frappe.set_route('Tree', 'Cost Center', {'company': frm.doc.name})
|
||||
frappe.set_route('Tree', 'Cost Center', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Account", 0, 'read')) {
|
||||
frm.add_custom_button(__('Chart of Accounts'), function() {
|
||||
frappe.set_route('Tree', 'Account', {'company': frm.doc.name})
|
||||
frappe.set_route('Tree', 'Account', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Sales Taxes and Charges Template", 0, 'read')) {
|
||||
frm.add_custom_button(__('Sales Tax Template'), function() {
|
||||
frappe.set_route('List', 'Sales Taxes and Charges Template', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
}
|
||||
|
||||
if (frappe.perm.has_perm("Purchase Taxes and Charges Template", 0, 'read')) {
|
||||
frm.add_custom_button(__('Purchase Tax Template'), function() {
|
||||
frappe.set_route('List', 'Purchase Taxes and Charges Template', {'company': frm.doc.name});
|
||||
}, __("View"));
|
||||
}
|
||||
|
||||
if (frm.has_perm('write')) {
|
||||
frm.add_custom_button(__('Default Tax Template'), function() {
|
||||
frm.trigger("make_default_tax_template");
|
||||
}, __('Create'));
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.company.set_chart_of_accounts_options(frm.doc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user