Try ERPNext Buy Support Partners Foundation

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/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", 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/core.py", 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/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 233, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 48, in migrate
    frappe.modules.patch_handler.run_all(skip_failing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 41, in run_all
    run_patch(patch)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 30, in run_patch
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 71, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 91, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v12_0/set_cwip_and_delete_asset_settings.py", 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/database.py", 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/__init__.py", line 364, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 350, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", 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")
frappe.db.commit()

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

hi @lasalesi i did run this but result still same