Error doctype delivery charges not found while migrating site

I uninstalles pos awesome after that i am facing problem with doctype like i was not able to acess sales invoice it was saying doctype pos offer not found now i am unable to update my site there is a error while migrating
“frappe.core.doctype.doctype.doctype.WrongOptionsDoctypeLinkError: Address: Options must be a valid DocType for field Delivery Charges in row 21”

any one know how to fix this issue.

There is no such doctype Named Delivery Charges it must be your custom Doctype.

anybody solve this issue ?

Why such an issue can occur?
For any app installed, there are some custom fields and doctypes installed.
However, when you uninstall the app, only doctypes are removed. Custom Fields Stay.

You get this error when there are link fields linked to removed doctypes.

How to resolve?
Delete linked custom fields.

These are the fields created. Search for Link and delete them from bench console.

You can use something like this as all field names start with posa_

frappe.db.delete("Custom Field", filters={"fieldname": ["like", "posa_%"]})
frappe.db.commit()

This should resolve your issue.

Possibly, Not actually- no customization by the user, someone else also reported the same error some days back to me on telegram. It could be due to some additional app which (non tech) users are not aware.
He didn’t customize any sort. Infact was also hosted on erp cloud instance!

@Smit_Vora Request you to put a disclaimer of Data Backup and removing field will loose data!

Only custom fields shall be deleted.

Actual data saved in those custom fields will not be deleted.

Data can be viewed again by installing the app again / recreating the fields.

1 Like

A better script can be run in the console, where you don’t what to delete old fields.

table = frappe.qb.DocType("Custom Field")
frappe.qb.update(table).set(table.fieldtype, "Data").set(table.options, "").where(table.fieldname.like("posa_%")).where(table.fieldtype == "Link").run()
frappe.db.commit()

This will convert fields with field type Link to Data.

1 Like

thank you

Did you actually run this script? I tried several different ways to get it running but it seems to be disabled due to security issues. See a similar observation by someone else here

I obtain the same error message as reported in the other thread.

Traceback (most recent call last):
File “apps/frappe/frappe/desk/doctype/system_console/system_console.py”, line 17, in run
safe_exec(self.console)
File “apps/frappe/frappe/utils/safe_exec.py”, line 85, in safe_exec
exec(
File “”, line 2, in
File “apps/frappe/frappe/query_builder/utils.py”, line 86, in execute_query
query, params = prepare_query(query)
File “apps/frappe/frappe/query_builder/utils.py”, line 131, in prepare_query
raise frappe.PermissionError(“Only SELECT SQL allowed in scripting”)
frappe.exceptions.PermissionError: Only SELECT SQL allowed in scripting

To reply to my own question: The suggested solution worked. My confusion was that I used the system console and/or server script instead of bench console.
In my case, just changing the doctype didn’t resolve the issue. I went with the deletion suggestion:

frappe.db.delete("Custom Field", filters={"fieldname": ["like", "posa_%"]})
frappe.db.commit()