Merge pull request #17554 from surajshetty3416/fix-rename-account-develop
fix: Show "Merge Account" button only to users with write access
diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js
index bb059f6..f7f1a5f 100644
--- a/erpnext/accounts/doctype/account/account.js
+++ b/erpnext/accounts/doctype/account/account.js
@@ -42,15 +42,14 @@
// show / hide convert buttons
frm.trigger('add_toolbar_buttons');
}
- frm.add_custom_button(__('Update Account Name / Number'), function () {
- frm.trigger("update_account_number");
- });
- }
-
- if(!frm.doc.__islocal) {
- frm.add_custom_button(__('Merge Account'), function () {
- frm.trigger("merge_account");
- });
+ if (frm.has_perm('write')) {
+ frm.add_custom_button(__('Update Account Name / Number'), function () {
+ frm.trigger("update_account_number");
+ });
+ frm.add_custom_button(__('Merge Account'), function () {
+ frm.trigger("merge_account");
+ });
+ }
}
},
account_type: function (frm) {
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index ecf67dd..68efe37 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -268,7 +268,7 @@
new_name = get_account_autoname(account_number, account_name, account.company)
if name != new_name:
- frappe.rename_doc("Account", name, new_name, ignore_permissions=1)
+ frappe.rename_doc("Account", name, new_name, force=1)
return new_name
@frappe.whitelist()
@@ -287,7 +287,7 @@
frappe.db.set_value("Account", new, "parent_account",
frappe.db.get_value("Account", old, "parent_account"))
- frappe.rename_doc("Account", old, new, merge=1, ignore_permissions=1)
+ frappe.rename_doc("Account", old, new, merge=1, force=1)
return new