frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.05k stars 7.21k forks source link

Uncaught Server Exception after changing Module Name #37412

Closed Seedthrower closed 8 months ago

Seedthrower commented 1 year ago

Information about bug

I tried to change the name of Manufacturing to Operations and it threw up the following error:

Uncaught Server Exception There was an error building this page

I then tried to change the name back from Operations to Manufacturing and I received the error message listed below.

I expected to be able to change the name of the module without issue.

Module

manufacturing

Version

Frappe Version: 14 ERPNext Version: 14

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
    "chat": "0.0.1",
    "ecommerce_integrations": "1.18.2",
    "erpnext": "14.43.0",
    "ew_customization": "0.0.1",
    "frappe": "14.51.0",
    "helpdesk": "0.10.0",
    "hrms": "14.13.0",
    "payments": "0.0.1",
    "pdf_on_submit": "14.0.4",
    "propms": "1.7.0",
    "whitelabel": "0.0.1"
}

Route

Form/DocType/Operations

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 95, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1622, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/model/rename_doc.py", line 92, in update_document_title
    doc.rename(updated_name, merge=merge)
  File "apps/frappe/frappe/model/document.py", line 1020, in rename
    return self._rename(name=name, merge=merge, force=force, validate_rename=validate_rename)
  File "apps/frappe/frappe/model/document.py", line 1002, in _rename
    self.name = rename_doc(doc=self, new=name, merge=merge, force=force, validate=validate_rename)
  File "apps/frappe/frappe/model/rename_doc.py", line 154, in rename_doc
    out = old_doc.run_method("before_rename", old, new, merge) or {}
  File "apps/frappe/frappe/model/document.py", line 917, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1279, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1261, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 914, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 502, in before_rename
    self.validate_name(new)
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 868, in validate_name
    validate_route_conflict(self.doctype, self.name)
  File "apps/frappe/frappe/desk/utils.py", line 18, in validate_route_conflict
    [slug(d) for d in frappe.get_all(_doctype, pluck="name") if (doctype != _doctype and d != name)]
  File "apps/frappe/frappe/__init__.py", line 1939, in get_all
    return get_list(doctype, *args, **kwargs)
  File "apps/frappe/frappe/__init__.py", line 1911, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
  File "apps/frappe/frappe/model/db_query.py", line 190, in execute
    self.columns = self.get_table_columns()
  File "apps/frappe/frappe/model/db_query.py", line 533, in get_table_columns
    return get_table_columns(self.doctype)
  File "apps/frappe/frappe/model/meta.py", line 75, in get_table_columns
    return frappe.db.get_table_columns(doctype)
  File "apps/frappe/frappe/database/database.py", line 1178, in get_table_columns
    raise self.TableMissingError("DocType", doctype)
pymysql.err.ProgrammingError: ('DocType', 'Workspace')

Request Data

{
    "type": "POST",
    "args": {
        "doctype": "DocType",
        "docname": "Operations",
        "name": "Manufacturing",
        "enqueue": true,
        "merge": 0,
        "freeze": true,
        "freeze_message": "Updating related fields..."
    },
    "freeze": true,
    "freeze_message": "Updating related fields...",
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.model.rename_doc.update_document_title"
}

Response Data

{
    "exception": "pymysql.err.ProgrammingError: ('DocType', 'Workspace')"
}
Nihantra-Patel commented 8 months ago

Hi @Seedthrower,

First thing, It's not a bug.

Changing the default module name in erpnext isn't possible because it's connected to a lot of code and some integrated structures. If you need to modify or enhance the base functionality, you can do so by adding it to a custom app. However, renaming the module can cause many functions to break, so it's not recommended.

migrate the site. If the migration works, great! But if it doesn't, you need to do a few things. First, make sure you back up everything (site). Then, create a new site and restore the database. Finally, double-check to make sure everything is working correctly.

Thank You!