Bench update --patch showing errors (disable_cwip_accounting, set_cwip_and_delete_asset_settings)

bench update --patch
Backing up sites...
Patching sites...
Migrating bion.localhost
Executing erpnext.patches.v12_0.set_cwip_and_delete_asset_settings in bion.localhost (8fd2fc5e95d59e44)
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/", line 72, in _run_code
    exec code in run_globals
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 97, in <module>
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 18, in main
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 233, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 48, in migrate
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 41, in run_all
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 30, in run_patch
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 71, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 91, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v12_0/", line 12, in execute
    cwip_value = frappe.db.get_single_value("Asset Settings", "disable_cwip_accounting")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/", line 559, in get_single_value
    frappe.throw(_('Invalid field name: {0}').format(frappe.bold(fieldname)), self.InvalidColumnName)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 364, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 350, in msgprint
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 316, in _raise_exception
    raise raise_exception(msg)
frappe.database.database.InvalidColumnName: Invalid field name: <b>disable_cwip_accounting</b>

The process is stopping at a patch for ERPNext for V12.
You can try skipping the patch like so (by Lasalesi):

I have tried but its not working,

Becuase the system is just updating in db which patches are successfully done, its better to find the root cause which is not allowing system to complete the patch.

More details will help to support you in troubleshooting this. From which version are you updating to which version? Have you tried running the patch manually (this might give you more details)…

I think, I am updating from v9 to v12.
Is there any table called Asset Settings? This seems to be missing from the error.

It might be quite a jump from v9 to v12. Have you considered updating in steps? Yes, there is a doctype Asset Settings. As far as I understand there is a logic issue in the way bench migrate performs migrations: first it runs the patches and only after that it will create/update table definitions. This might be the issue in your case…

What I think that Asset setting table was introduced in version 9 on wards and its missing during this command.
Also, how do I explicitly run patches?

You can run

$ bench execute erpnext.patches.v12_0.set_cwip_and_delete_asset_settings.execute

for anyone else experiencing this problem, I was able to solve it with bench console with

frappe.delete_doc_if_exists("DocType", "Asset Settings")

hi i have same problem any idea how to fix this?

hi @lasalesi i did run this but result still same