ERPNext Conference 2019* ERPNext.com Blog

Cannot delete custom field in Event doctype


#1

Hey guys,
So I am trying to delete a custom field using the Customise option on the Event doctype.

The error received when trying to save the doctype is this: ImportError: cannot import name FileNotFoundError

Traceback from frappe.log

[ERROR] 2019-10-10 06:19:41,660 | /home/frappe/frappe-bench/apps/frappe/frappe/app.py:
Site: WEBSITE RETRACTED
Form Dict: {
 "cmd": "runserverobj",
 "docs": "{\"image_view\":0,\"track_changes\":1,\"doctype\":\"Customize Form\",\"sort_order\":\"DESC\",\"editable_grid\":0,\"max_attachments\":0,\"allow_auto_repeat\":0,\"a$
 "method": "save_customization"
}
Request Error
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 84, in runserverobj
    frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/run_method.py", line 36, in runserverobj
    except ValueError:
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1056, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1039, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/customize_form/customize_form.py", line 167, in save_customization
    self.update_custom_fields()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/customize_form/customize_form.py", line 259, in update_custom_fields
    self.delete_custom_fields()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/customize_form/customize_form.py", line 314, in delete_custom_fields
    frappe.delete_doc("Custom Field", df.name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 775, in delete_doc
    import frappe.model.delete_doc
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/delete_doc.py", line 19, in <module>
    from frappe.exceptions import FileNotFoundError
ImportError: cannot import name FileNotFoundError

#2

Guys, I really need your help with this… the problem is still there.

I cannot delete custom fields … anyone else experiencing this ?


#3

can you share a screenshot when does error raise!


#4

the error is import Error, cannot import name FileNotFoundError
on line 19 from frappe.exceptions import FileNotFoundError
frappe.model.delete_doc.py

the strange thing is when run the same on bench console there is no error

image

and after changed the code in delete_doc.py as following(copied the FileNotFoundError declaration from the original exceptions.py)

image

error fixed, but I have no idea WHY.