Chart of account not update if Company Abbreviation changed

Queue / Worker	Job	Created
Traceback (most recent call last):
  File "/home/vishal/frappe-bench-production/env/local/lib/python2.7/site-packages/rq/", line 793, in perform_job
    rv = job.perform()
  File "/home/vishal/frappe-bench-production/env/local/lib/python2.7/site-packages/rq/", line 599, in perform
    self._result = self._execute()
  File "/home/vishal/frappe-bench-production/env/local/lib/python2.7/site-packages/rq/", line 605, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/home/vishal/frappe-bench-production/apps/frappe/frappe/utils/", line 97, in execute_job
  File "/home/vishal/frappe-bench-production/apps/erpnext/erpnext/setup/doctype/company/", line 340, in replace_abbr
  File "/home/vishal/frappe-bench-production/apps/erpnext/erpnext/setup/doctype/company/", line 337, in _rename_records
  File "/home/vishal/frappe-bench-production/apps/erpnext/erpnext/setup/doctype/company/", line 331, in _rename_record
    frappe.rename_doc(dt, doc[0], parts[0] + " - " + new)
  File "/home/vishal/frappe-bench-production/apps/frappe/frappe/", line 700, in rename_doc
    return rename_doc(*args, **kwargs)
  File "/home/vishal/frappe-bench-production/apps/frappe/frappe/model/", line 39, in rename_doc
    new = validate_rename(doctype, new, meta, merge, force, ignore_permissions)
  File "/home/vishal/frappe-bench-production/apps/frappe/frappe/model/", line 132, in validate_rename
    frappe.msgprint(_("{0} not allowed to be renamed").format(_(doctype)), raise_exception=1)
  File "/home/vishal/frappe-bench-production/apps/frappe/frappe/", line 309, in msgprint
  File "/home/vishal/frappe-bench-production/apps/frappe/frappe/", line 284, in _raise_exception
    raise ValidationError(encode(msg))
ValidationError: Account not allowed to be renamed

master branch

1 Like

I had the same issue, please also make a GitHub issue for this.

I’m using a workaround by copying the replace_abbr function from into bench console with one slight modification: adding an argument force=True in the function frappe.rename_doc(dt, doc[0], parts[0] + " - " + new, force=True)

So basically if you’re comfortable with Python and bench console you can copy the function and call it from bench console:

def replace_abbr(company, old, new):
	new = new.strip()
	if not new:
		frappe.throw(_("Abbr can not be blank or space"))

	frappe.only_for("System Manager")

	frappe.db.set_value("Company", company, "abbr", new)

	def _rename_record(doc):
		parts = doc[0].rsplit(" - ", 1)
		if len(parts) == 1 or parts[1].lower() == old.lower():
			frappe.rename_doc(dt, doc[0], parts[0] + " - " + new, force=True)

	def _rename_records(dt):
		# rename is expensive so let's be economical with memory usage
		doc = (d for d in frappe.db.sql("select name from `tab%s` where company=%s" % (dt, '%s'), company))
		for d in doc:

	for dt in ["Warehouse", "Account", "Cost Center"]: