Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46

I’m getting this error when using bench migrate. I can’t find tax detail at all. Was it removed or am I missing it for erpnext v15?

erpadmin@ERPnext:~/frappe-bench$ bench migrate
Migrating site1.local
Updating DocTypes for frappe : [========================================] 100%
Updating DocTypes for erpnext : [========================================] 100%
Updating DocTypes for hrms : [========================================] 100%
Updating DocTypes for payments : [========================================] 100%
Executing execute:frappe.delete_doc_if_exists(“Report”, “Tax Detail”) in site1.local (_8ef9799eac8e54e6)
Queued rebuilding of search index for site1.local

Traceback with variables (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,
mod_name = ‘frappe.utils.bench_helper’
alter_argv = True
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>, origin=‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
code = <code object at 0x7f369c111210, file “/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 1>
main_globals = {‘name’: ‘main’, ‘doc’: None, ‘package’: ‘frappe.utils’, ‘loader’: <_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>, origin=‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’), ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘file’: ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘cached’: ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.10/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.10/json/init.py’>, ‘os’: <module ‘os’ from ‘/usr/lib/python3.10/os.py’>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.10/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.10/warnings.py’>, ‘Path…
File “/usr/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
code = <code object at 0x7f369c111210, file “/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 1>
run_globals = {‘name’: ‘main’, ‘doc’: None, ‘package’: ‘frappe.utils’, ‘loader’: <_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>, origin=’/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’), ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘file’: ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘cached’: ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.10/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.10/json/init.py’>, ‘os’: <module ‘os’ from ‘/usr/lib/python3.10/os.py’>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.10/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.10/warnings.py’>, ‘Path…
init_globals = None
mod_name = ‘main
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>, origin=’/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
pkg_name = ‘frappe.utils’
script_name = None
loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f369dcceb30>
fname = ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’
cached = ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 114, in
main()
…skipped… 27 vars
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 20, in main
click.Group(commands=commands)(prog_name=“bench”)
commands = {‘frappe’: , ‘get-frappe-commands’: , ‘get-frappe-help’: }
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1157, in call
return self.main(*args, **kwargs)
self =
args = ()
kwargs = {‘prog_name’: ‘bench’}
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
self =
args = [‘frappe’, ‘migrate’]
prog_name = ‘bench’
complete_var = None
standalone_mode = True
windows_expand_args = True
extra = {}
ctx = <click.core.Context object at 0x7f369c105de0>
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7f369c1175b0>
args = [‘migrate’]
cmd_name = ‘frappe’
cmd =
sub_ctx = <click.core.Context object at 0x7f369c18eb90>
ctx = <click.core.Context object at 0x7f369c105de0>
self =
class = <class ‘click.core.MultiCommand’>
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7f369c196320>
args = []
cmd_name = ‘migrate’
cmd =
sub_ctx = <click.core.Context object at 0x7f369c18efb0>
ctx = <click.core.Context object at 0x7f369c18eb90>
self =
class = <class ‘click.core.MultiCommand’>
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
self =
ctx = <click.core.Context object at 0x7f369c18efb0>
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 783, in invoke
return __callback(*args, **kwargs)
_Context__self = <click.core.Context object at 0x7f369c18efb0>
_Context__callback = <function migrate at 0x7f369c13ecb0>
args = ()
kwargs = {‘skip_failing’: False, ‘skip_search_index’: False}
ctx = <click.core.Context object at 0x7f369c18efb0>
File “/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py”, line 33, in new_func
return f(get_current_context(), *args, **kwargs)
args = ()
kwargs = {‘skip_failing’: False, ‘skip_search_index’: False}
f = <function migrate at 0x7f369c13ea70>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/commands/init.py”, line 29, in _func
ret = f(frappe.dict(ctx.obj), *args, **kwargs)
ctx = <click.core.Context object at 0x7f369c18efb0>
args = ()
kwargs = {‘skip_failing’: False, ‘skip_search_index’: False}
profile = False
f = <function migrate at 0x7f369c13e9e0>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/commands/site.py”, line 596, in migrate
SiteMigration(
context = {‘sites’: [‘site1.local’], ‘force’: False, ‘verbose’: False, ‘profile’: False}
skip_failing = False
skip_search_index = False
activate_by_import = <module ‘traceback_with_variables.activate_by_import’ from ‘/home/erpadmin/frappe-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py’>
SiteMigration = <class ‘frappe.migrate.SiteMigration’>
site = ‘site1.local’
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/migrate.py”, line 179, in run
self.run_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x7f369c18ee30>
site = ‘site1.local’
filelock = <function filelock at 0x7f36996da680>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/migrate.py”, line 41, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x7f369c18ee30>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x7f36996da290>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/migrate.py”, line 114, in run_schema_updates
frappe.modules.patch_handler.run_all(
self = <frappe.migrate.SiteMigration object at 0x7f369c18ee30>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 76, in run_all
run_patch(patch)
patch_type = <PatchType.post_model_sync: ‘post_model_sync’>
executed = {‘erpnext.patches.v13_0.replace_pos_payment_mode_table #2020-12-29’, ‘erpnext.patches.v12_0.set_cwip_and_delete_asset_settings’, “execute:frappe.delete_doc_if_exists(‘DocType’, ‘GSuite Templates’)”, ‘erpnext.patches.v12_0.create_accounting_dimensions_in_missing_doctypes #2020-05-11’, ‘frappe.patches.v11_0.rename_workflow_action_to_workflow_action_master #13-06-2018’, ‘execute:frappe.delete_doc_if_exists(“Page”, “production-analytics”)’, ‘frappe.patches.v13_0.set_existing_dashboard_charts_as_public’, ‘erpnext.patches.v13_0.remove_bad_selling_defaults’, ‘erpnext.patches.v11_0.update_delivery_trip_status’, ‘frappe.patches.v12_0.delete_duplicate_indexes # 2022-12-15’, ‘frappe.patches.v11_0.rename_standard_reply_to_email_template’, ‘erpnext.patches.v11_0.update_allow_transfer_for_manufacture’, ‘erpnext.patches.v14_0.update_subscription_details’, ‘execute:frappe.delete_doc(“Report”, “Department Analytics”)’, ‘erpnext.patches.v15_0.update_gpa_and_ndb_for_assdeprsch’, 'frappe.patches.v12_0.de…
run_patch = <function run_all..run_patch at 0x7f3698e94ee0>
patches = [“execute:frappe.get_doc(‘Role’, ‘Guest’).save() # remove desk access”, ‘frappe.core.doctype.role.patches.v13_set_default_desk_properties’, ‘frappe.patches.v14_0.update_workspace2 # 06.06.2023’, ‘frappe.patches.v14_0.drop_data_import_legacy’, ‘frappe.patches.v14_0.copy_mail_data #08.03.21’, ‘frappe.patches.v14_0.update_github_endpoints #08-11-2021’, ‘frappe.patches.v14_0.remove_db_aggregation’, ‘frappe.patches.v14_0.update_color_names_in_kanban_board_column’, ‘frappe.patches.v14_0.update_is_system_generated_flag’, ‘frappe.patches.v14_0.update_auto_account_deletion_duration’, ‘frappe.patches.v14_0.update_integration_request’, ‘frappe.patches.v14_0.set_document_expiry_default’, ‘frappe.patches.v14_0.delete_data_migration_tool’, ‘frappe.patches.v14_0.set_suspend_email_queue_default’, ‘frappe.patches.v14_0.different_encryption_key’, ‘frappe.patches.v14_0.update_multistep_webforms’, “execute:frappe.delete_doc(‘Page’, ‘background_jobs’, ignore_missing=True, force=True)”, 'frappe.patches.v14

patch = ‘execute:frappe.delete_doc_if_exists(“Report”, “Tax Detail”)’
skip_failing = False
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 62, in run_patch
if not run_single(patchmodule=patch):
patch = ‘execute:frappe.delete_doc_if_exists(“Report”, “Tax Detail”)’
skip_failing = False
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 153, in run_single
return execute_patch(patchmodule, method, methodargs)
patchmodule = ‘execute:frappe.delete_doc_if_exists(“Report”, “Tax Detail”)’
method = None
methodargs = None
force = False
conf =
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 191, in execute_patch
exec(patch, globals())
patchmodule = ‘execute:frappe.delete_doc_if_exists(“Report”, “Tax Detail”)’
method = None
methodargs = None
has_patch_file = False
patch = ‘frappe.delete_doc_if_exists(“Report”, “Tax Detail”)’
docstring = ‘’
start_time = 57821.915760815
File “”, line 1, in
…skipped… 26 vars
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/init.py”, line 1340, in delete_doc_if_exists
delete_doc(doctype, name, force=force, ignore_missing=True)
doctype = ‘Report’
name = ‘Tax Detail’
force = 0
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/init.py”, line 1324, in delete_doc
return frappe.model.delete_doc.delete_doc(
doctype = ‘Report’
name = ‘Tax Detail’
force = 0
ignore_doctypes = None
for_reload = False
ignore_permissions = False
flags = None
ignore_on_trash = False
ignore_missing = True
delete_permanently = False
frappe = <module ‘frappe’ from ‘/home/erpadmin/frappe-bench/apps/frappe/frappe/init.py’>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 119, in delete_doc
check_if_doc_is_dynamically_linked(doc)
doctype = ‘Report’
name = ‘Tax Detail’
force = 0
ignore_doctypes = []
for_reload = False
ignore_permissions = False
flags = None
ignore_on_trash = False
ignore_missing = True
delete_permanently = False
is_virtual = 0
names = [‘Tax Detail’]
doc = <Report: Tax Detail>
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 340, in check_if_doc_is_dynamically_linked
raise_link_exists_exception(doc, reference_doctype, reference_docname, at_position)
doc = <Report: Tax Detail>
method = ‘Delete’
df = {‘parent’: ‘Workspace Link’, ‘read_only’: 0, ‘in_create’: 0, ‘fieldname’: ‘link_to’, ‘options’: ‘link_type’, ‘table’: ‘, parent, parenttype, idx’}
ignore_linked_doctypes = []
meta = <Meta: Workspace Link>
refdoc = {‘name’: ‘70bb69c30e’, ‘docstatus’: 0, ‘parent’: ‘Accounting’, ‘parenttype’: ‘Workspace’, ‘idx’: 46}
reference_doctype = ‘Workspace’
reference_docname = ‘Accounting’
at_position = ‘at Row: 46’
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 353, in raise_link_exists_exception
frappe.throw(
doc = <Report: Tax Detail>
reference_doctype = ‘Workspace’
reference_docname = ‘Accounting’
row = ‘at Row: 46’
doc_link = ‘Tax Detail
reference_link = ‘Accounting
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/init.py”, line 570, in throw
msgprint(
msg = ‘Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46’
exc = <class ‘frappe.exceptions.LinkExistsError’>
title = None
is_minimizable = False
wide = False
as_list = False
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/init.py”, line 542, in msgprint
_raise_exception()
title = None
as_table = False
as_list = False
indicator = ‘red’
alert = False
primary_action = None
is_minimizable = False
wide = False
sys = <module ‘sys’ (built-in)>
_raise_exception = <function msgprint.._raise_exception at 0x7f3698e94f70>
_strip_html_tags = <functools._lru_cache_wrapper object at 0x7f3698e926c0>
msg = ‘Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46’
out = {‘message’: ‘Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1, ‘__frappe_exc_id’: ‘511ce174ceab6732e6971c0c64ff1077fb0f97496c9ad0c7c2cefa5b’}
raise_exception = <class ‘frappe.exceptions.LinkExistsError’>
strip_html_tags = <function strip_html_tags at 0x7f369c9c0820>
…skipped… 1 vars
File “/home/erpadmin/frappe-bench/apps/frappe/frappe/init.py”, line 496, in _raise_exception
raise exc
exc = LinkExistsError(‘Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46’)
msg = ‘Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46’
out = {‘message’: ‘Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1, ‘__frappe_exc_id’: ‘511ce174ceab6732e6971c0c64ff1077fb0f97496c9ad0c7c2cefa5b’}
raise_exception = <class ‘frappe.exceptions.LinkExistsError’>
…skipped… 1 vars
frappe.exceptions.LinkExistsError: Cannot delete or cancel because Report Tax Detail is linked with Workspace Accounting at Row: 46

I have resolved this issue by deleting the tax detail from the tabworkspace link table in the database and then executing “bench migrate”.
Perhaps you may also need to delete the data related to KSA at the same time.

Hi Yanwan,

Could you possibly guide me in how to access my database and specifically find that? I’m not too familiar with mariadb and the commands needed. I’d appreicate any links or videos.

step 1

bench mariadb

step 2 Find information about the row number in the message.

select idx,lable from `tabWorkspace Link`;

step 3 Delete the desired row data from the database.

delete from  `tabWorkspace Link` where idx=46;

Important note: Please make a backup of your data before performing the above operations.