[Solved] Bench Update Error frappe.exceptions.LinkExistsError, Cannot delete or cancel because Report Project Profitability is linked with Workspace Projects-Administrator at Row

Hi Guys.

Was trying to bench update , Now i am getting this error.

frappe.exceptions.LinkExistsError: Cannot delete or cancel because Report Project Profitability is linked with Workspace Projects-Administrator at Row: 14

I also tried to bench migrate, after bench update --pull. But faced with same error.

Here is the log :

Updating DocTypes for frappe : [========================================] 100%
Updating DocTypes for erpnext : [========================================] 100%
Executing erpnext.patches.v14_0.remove_hr_and_payroll_modules # 20-07-2022 in mysite.com (_cd74b1a16af2aad0)
Updating Dashboard for frappe
Updating Dashboard for erpnext
Updating customizations for Address
Updating customizations for Contact
Building search index for mysite.com
Retrieving Routes : [========================================] 100%
Building Index : [========================================] 100%
Traceback (most recent call last):
File “/usr/lib/python3.10/runpy.py”, line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
File “/home/bench/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 109, in
main()
File “/home/bench/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=“bench”)
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/home/bench/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/bench/frappe-bench/apps/frappe/frappe/commands/init.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/bench/frappe-bench/apps/frappe/frappe/commands/site.py”, line 524, in migrate
SiteMigration(
File “/home/bench/frappe-bench/apps/frappe/frappe/migrate.py”, line 172, in run
self.run_schema_updates()
File “/home/bench/frappe-bench/apps/frappe/frappe/migrate.py”, line 40, in wrapper
ret = method(*args, **kwargs)
File “/home/bench/frappe-bench/apps/frappe/frappe/migrate.py”, line 113, in run_schema_updates
frappe.modules.patch_handler.run_all(
File “/home/bench/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 75, in run_all
run_patch(patch)
File “/home/bench/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 62, in run_patch
if not run_single(patchmodule=patch):
File “/home/bench/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 150, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/bench/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 185, in execute_patch
_patch()
File “/home/bench/frappe-bench/apps/erpnext/erpnext/patches/v14_0/remove_hr_and_payroll_modules.py”, line 34, in execute
frappe.delete_doc(“Report”, report, ignore_missing=True)
File “/home/bench/frappe-bench/apps/frappe/frappe/init.py”, line 1233, in delete_doc
return frappe.model.delete_doc.delete_doc(
File “/home/bench/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 124, in delete_doc
check_if_doc_is_dynamically_linked(doc)
File “/home/bench/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 343, in check_if_doc_is_dynamically_linked
raise_link_exists_exception(doc, reference_doctype, reference_docname, at_position)
File “/home/bench/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 356, in raise_link_exists_exception
frappe.throw(
File “/home/bench/frappe-bench/apps/frappe/frappe/init.py”, line 521, in throw
msgprint(
File “/home/bench/frappe-bench/apps/frappe/frappe/init.py”, line 489, in msgprint
_raise_exception()
File “/home/bench/frappe-bench/apps/frappe/frappe/init.py”, line 441, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.LinkExistsError: Cannot delete or cancel because Report Project Profitability is linked with Workspace Projects-Administrator at Row: 14

Any help would be really appreciated.

Not sure , but if you have front end access , then just open Workspace - > Project Administration and delete Report Project Profitability from row no 14 then do bench migrate

check report Project Profitability is under which module?

Thanks for the reply.
Nope I don’t have access to frontend, Since i did the bench update , It says error 503 Updating…

Can this be changed from Backend?, May be db?.

yes, try this “bench set-maintenance-mode off” in bench directory and try to access application

Yes I have tried it, But it still says the same Updating.

I also checked common_site_config.json and site_config.json, I can see` maintenance_mode:0

image

Is there anyway I can delete Report Project Profitability through DB access?

you can remove ‘Project profitability’ from report list in remove_hr_and_payroll_modules.py line no 28 and run bench migrate again

for refernce : erpnext/remove_hr_and_payroll_modules.py at 5a3999e236762466239818fbcf109be15665a959 · frappe/erpnext · GitHub

1 Like

Thanks @abrarpv97, As you mentioned I have removed it from that lines and the migration went smooth.

Once I got the Frontend Access, I have removed those reports from Projects Workspace.

Now let me try checkout the file remove_hr_and_payroll_modules.py and do one more bench migrate.

[UPDATE]
So I have successfully migrated, And I don’t have any local change to conflict future update.

Thanks Abrar :pray:

2 Likes