V8 update errror with patch frappe.patches.v8_0.rename_page_role_to_has_role

Please find the traceback.

Executing frappe.patches.v8_0.rename_page_role_to_has_role #2017-03-16 in site1.local (1bd3e0294da19198)
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, 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/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/ubuntu/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/ubuntu/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/site.py”, line 210, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
frappe.modules.patch_handler.run_all()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/patches/v8_0/rename_page_role_to_has_role.py”, line 12, in execute
copy_user_roles_to_has_roles()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/patches/v8_0/rename_page_role_to_has_role.py”, line 35, in copy_user_roles_to_has_roles
doc = frappe.get_doc(‘User’, data.name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 606, in get_doc
return frappe.model.document.get_doc(arg1, arg2)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 51, in get_doc
return controller(arg1, arg2)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 84, in init
self.load_from_db()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 130, in load_from_db
self.set(df.fieldname, children)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 122, in set
self.extend(key, value)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 148, in extend
self.append(key, v)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 136, in append
value = self._init_child(value, key)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 163, in _init_child
value = get_controller(value[“doctype”])(value)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 34, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 184, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for UserRole (frappe.core.doctype.userrole.userrole)

the folder userrole in frappe core is empty. Thanks for your support.

Pushed a potential fix, please update again and check.

Thanks @nabinhait. Pulled new version but still same error.

Try following:

bench --site <your-site-name> console
frappe.reload_doc("core", 'doctype', "has_role", force=True)
frappe.reload_doc("core", 'doctype', "user", force=True)
frappe.db.commit()
exit()

Then run bench update --upgrade again.