Module import failed for Has Role (frappe.core.doctype.has_role.has_role)

Hi,

I am at wits end trying to update an older version of frappe/erpnext backup(I cannot lose this backup)

frappe@server:~/frappe-bench$ bench --site erp.localhost migrate
Migrating erp.localhost
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2017-01-06 in erp.localhost (cfd511bd42)
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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, 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 716, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/frappe/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/frappe/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/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 209, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 30, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 81, in execute_patch
exec patchmodule.split(“execute:”)[1] in globals()
File “”, line 1, in
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 654, in reload_doc
return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 141, in reload_doc
return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 19, in import_files
reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 24, in import_file
ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 57, in import_file_by_path
reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 125, in import_doc
doc.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 204, in insert
d.db_insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 296, in db_insert
), d.values())
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 137, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1048, “Column ‘in_global_search’ cannot be null”)

What I did next was change the default value for the tabDocfield column “in_global_search”

Next I get this unresolved error

frappe@server:~/frappe-bench$ bench --site erp.localhost migrate
Migrating erp.localhost
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2017-01-06 in erp.localhost (cfd511bd42)
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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, 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 716, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/frappe/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/frappe/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/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 209, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 30, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 84, in execute_patch
update_patch_log(patchmodule)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 101, in update_patch_log
frappe.get_doc({“doctype”: “Patch Log”, “patch”: patchmodule}).insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 186, in insert
self.validate_higher_perm_levels()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 435, in validate_higher_perm_levels
has_access_to = self.get_permlevel_access()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 450, in get_permlevel_access
user_roles = frappe.get_roles()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 359, in get_roles
return get_user().get_roles()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 347, in get_user
local.user_perms = UserPermissions(local.session.user)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line 35, in init
self.setup_user()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line 51, in setup_user
user_doc = frappe.cache().hget(“user_doc”, self.name, get_user_doc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 171, in hget
value = generator()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line 41, in get_user_doc
user = frappe.get_doc(“User”, self.name).as_dict()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 597, in get_doc
return frappe.model.document.get_doc(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 50, in get_doc
return controller(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 83, in init
self.load_from_db()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 129, in load_from_db
self.set(df.fieldname, children)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 122, in set
self.extend(key, value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 148, in extend
self.append(key, v)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 136, in append
value = self._init_child(value, key)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 163, in _init_child
value = get_controller(value[“doctype”])(value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 34, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 173, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for Has Role (frappe.core.doctype.has_role.has_role)
frappe@server:~/frappe-bench$

Both ERPNEXT and Frappe are on master

Hi @slushpuppy

Seems frappe and erpnext are on older version, kindly pull the latest update and check.

They are on develop branch

@rohit_w

Hi, Thanks for the reply,

I performed the “bench update”

frappe@server:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.app:pulling erpnext
    From https://github.com/frappe/erpnext
  • branch master -> FETCH_HEAD
    Already up-to-date.
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-lqDMOw/frappe/

/bin/sh: 1: cd: can’t cd to /home/frappe/frappe-bench/frappe-bench

Also I did the command, bench switch-to-master before trying to migrate

frappe@server:~/frappe-bench$ bench switch-to-master
Switching for frappe
Already on ‘master’
Your branch is up-to-date with ‘upstream/master’.
Already up-to-date.
remote: Counting objects: 50, done.
remote: Total 50 (delta 42), reused 42 (delta 42), pack-reused 7
Unpacking objects: 100% (50/50), done.
From https://github.com/frappe/erpnext
9ba1be6…00b04ed develop -> upstream/develop
Switching for erpnext
Already on ‘master’
Your branch is up-to-date with ‘upstream/master’.
Already up-to-date.
Successfully switched branches for:

Hi @slushpuppy

After switch to master, did you run command bench migrate?

Hi @rohit_w

Thanks once again for replying, the error still occurs

after typing bench --site site_name migrate

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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line
79, in
main()
File
“/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line
16, 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 716, in call
return self.main(*args, **kwargs)
File
“/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”,
line 696, in main
rv = self.invoke(ctx)
File
“/home/frappe/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/frappe/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/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”,
line 534, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”,
line 209, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 30,
in migrate
frappe.modules.patch_handler.run_all()
File
“/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”,
line 29, in run_all
if not run_single(patchmodule = patch):
File
“/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”,
line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”,
line 84, in execute_patch
update_patch_log(patchmodule)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”,
line 101, in update_patch_log
frappe.get_doc({“doctype”: “Patch Log”, “patch”: patchmodule}).insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”,
line 186, in insert
self.validate_higher_perm_levels()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”,
line 435, in validate_higher_perm_levels
has_access_to = self.get_permlevel_access()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”,
line 450, in get_permlevel_access
user_roles = frappe.get_roles()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line
359, in get_roles
return get_user().get_roles()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line
347, in get_user
local.user_perms = UserPermissions(local.session.user)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line
35, in init
self.setup_user()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line
51, in setup_user
user_doc = frappe.cache().hget(“user_doc”, self.name, get_user_doc)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line
171, in hget
value = generator()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line
41, in get_user_doc
user = frappe.get_doc(“User”, self.name).as_dict()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line
597, in get_doc
return frappe.model.document.get_doc(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”,
line 50, in get_doc
return controller(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”,
line 83, in init
self.load_from_db()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”,
line 129, in load_from_db
self.set(df.fieldname, children)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line
122, in set
self.extend(key, value)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line
148, in extend
self.append(key, v)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line
136, in append
value = self._init_child(value, key)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line
163, in _init_child
value = get_controller(value[“doctype”])(value)
File
“/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line
34, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”,
line 173, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype,
module_name)
ImportError: Module import failed for Has Role
(frappe.core.doctype.has_role.has_role)
frappe@server:~/frappe-bench$ bench update

Hi @slushpuppy

Can you reload the supervisor and run bench migrate

Hi @rohit_w

frappe@server:~$ sudo service supervisor reload
[sudo] password for frappe:
Usage: /etc/init.d/supervisord {start|stop|restart|force-reload|status|force-stop}
frappe@server:~$ sudo service supervisor force-reload
frappe@server:~$ cd bench-repo/
bench/ bench.egg-info/ .git/ install_scripts/ playbooks/ vm/
frappe@server:~$ cd frappe-bench/
frappe@server:~/frappe-bench$ bench --site erp.localhost migrate
Migrating erp.localhost
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2017-01-06 in erp.localhost (cfd511bd42)
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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, 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 716, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/frappe/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/frappe/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/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 209, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 30, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 84, in execute_patch
update_patch_log(patchmodule)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 101, in update_patch_log
frappe.get_doc({“doctype”: “Patch Log”, “patch”: patchmodule}).insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 186, in insert
self.validate_higher_perm_levels()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 435, in validate_higher_perm_levels
has_access_to = self.get_permlevel_access()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 450, in get_permlevel_access
user_roles = frappe.get_roles()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 359, in get_roles
return get_user().get_roles()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 347, in get_user
local.user_perms = UserPermissions(local.session.user)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line 35, in init
self.setup_user()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line 51, in setup_user
user_doc = frappe.cache().hget(“user_doc”, self.name, get_user_doc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 171, in hget
value = generator()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/user.py”, line 41, in get_user_doc
user = frappe.get_doc(“User”, self.name).as_dict()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 597, in get_doc
return frappe.model.document.get_doc(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 50, in get_doc
return controller(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 83, in init
self.load_from_db()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 129, in load_from_db
self.set(df.fieldname, children)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 122, in set
self.extend(key, value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 148, in extend
self.append(key, v)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 136, in append
value = self._init_child(value, key)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 163, in _init_child
value = get_controller(value[“doctype”])(value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 34, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 173, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for Has Role (frappe.core.doctype.has_role.has_role)

Still no go, please advise

Thanks!

Hi @slushpuppy

You need to switch to the develop branch and has to run bench update

Hi @rohit_w

Thanks once again for helping.

I received a new error:

frappe@server:~/frappe-bench$ bench switch-to-develop
remote: Counting objects: 119, done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 119 (delta 75), reused 25 (delta 25), pack-reused 1
Receiving objects: 100% (119/119), 58.73 KiB | 0 bytes/s, done.
Resolving deltas: 100% (75/75), completed with 25 local objects.
From https://github.com/frappe/frappe
ca1cd65…7777b3a master -> upstream/master
79620ab…cd4fd83 develop -> upstream/develop
ec1f8e4…7777b3a hotfix -> upstream/hotfix

  • [new branch] revert-2937-develop_customize_form_report_hide_fixes -> upstream/revert-2937-develop_customize_form_report_hide_fixes
  • [new tag] v7.2.31 -> v7.2.31
    Switching for frappe
    Switched to branch ‘develop’
    Updating 6588cf4…cd4fd83
    Fast-forward
    frappe/init.py | 5 +++±
    frappe/core/doctype/feedback_trigger/feedback_trigger.py | 4 +±-
    frappe/core/doctype/role_permission_for_page_and_report/role_permission_for_page_and_report.js | 8 +++++±-
    frappe/core/page/user_permissions/user_permissions.py | 8 ++++++±
    frappe/desk/reportview.py | 2 ±
    frappe/email/doctype/email_alert/email_alert.py | 6 +++±-
    frappe/email/receive.py | 2 ±
    frappe/geo/doctype/address/address.py | 2 ±
    frappe/public/js/frappe/model/create_new.js | 7 +++++±
    frappe/public/js/frappe/ui/listing.js | 5 +++±
    frappe/public/js/legacy/clientscriptAPI.js | 2 ±
    frappe/public/js/legacy/form.js | 4 +±-
    frappe/templates/includes/search_box.html | 2 ±
    frappe/utils/help.py | 2 ±
    frappe/website/doctype/web_page/templates/web_page_row.html | 4 ++++
    frappe/website/doctype/web_page/web_page.json | 6 ++±–
    16 files changed, 48 insertions(+), 21 deletions(-)
    create mode 100644 frappe/website/doctype/web_page/templates/web_page_row.html
    remote: Counting objects: 93, done.
    remote: Compressing objects: 100% (5/5), done.
    remote: Total 93 (delta 61), reused 60 (delta 60), pack-reused 27
    Unpacking objects: 100% (93/93), done.
    From https://github.com/frappe/erpnext
    c1a5b34…3e43f27 master -> upstream/master
    00b04ed…46e108b develop -> upstream/develop
    d25e314…3e43f27 hotfix -> upstream/hotfix
  • [new tag] v7.2.31 -> v7.2.31
    Switching for erpnext
    Branch develop set up to track remote branch develop from upstream.
    Switched to a new branch ‘develop’
    Already up-to-date.
    Successfully switched branches for:
    frappe
    erpnext

Switched to develop
Please run bench update --patch to be safe from any differences in database schema
frappe@server:~/frappe-bench$ bench update --patch
Migrating erp.localhost
Executing frappe.patches.v7_2.set_in_standard_filter_property #1 in erp.localhost (cfd511bd42)
/home/frappe/frappe-bench/apps/erpnext/erpnext/utilities/doctype/address_template/address_template.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/schools/doctype/assessment/assessment.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/buying/doctype/quality_inspection/quality_inspection.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/schools/doctype/discussion/discussion.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/payment_gateway/payment_gateway.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/schools/doctype/announcement/announcement.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/schools/doctype/topic/topic.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/utilities/doctype/address/address.json missing
/home/frappe/frappe-bench/apps/erpnext/erpnext/utilities/doctype/contact/contact.json missing
Success
Executing execute:frappe.db.sql(“update tabCommunication set communication_date = creation where time(communication_date) = 0”) in erp.localhost (cfd511bd42)
Success
Executing frappe.patches.v7_2.fix_email_queue_recipient in erp.localhost (cfd511bd42)
Success
Executing frappe.patches.v7_2.update_feedback_request # 2017-02-27 in erp.localhost (cfd511bd42)
Success
Executing execute:frappe.rename_doc(‘Country’, ‘Macedonia, Republic of’, ‘Macedonia’, ignore_if_exists=True) in erp.localhost (cfd511bd42)
Success
Executing execute:frappe.rename_doc(‘Country’, ‘Iran, Islamic Republic of’, ‘Iran’, ignore_if_exists=True) in erp.localhost (cfd511bd42)
Success
Executing execute:frappe.rename_doc(‘Country’, ‘Tanzania, United Republic of’, ‘Tanzania’, ignore_if_exists=True) in erp.localhost (cfd511bd42)
Success
Executing execute:frappe.rename_doc(‘Country’, ‘Syrian Arab Republic’, ‘Syria’, ignore_if_exists=True) in erp.localhost (cfd511bd42)
Success
Executing frappe.patches.v8_0.rename_listsettings_to_usersettings in erp.localhost (cfd511bd42)
Success
Executing frappe.patches.v7_2.update_communications in erp.localhost (cfd511bd42)
Success
Executing frappe.patches.v8_0.deprecate_integration_broker in erp.localhost (cfd511bd42)
Success
Executing frappe.patches.v8_0.setup_email_inbox in erp.localhost (cfd511bd42)
Success
Executing execute:frappe.reload_doc(‘accounts’, ‘doctype’, ‘accounts_settings’) in erp.localhost (cfd511bd42)
Success
Executing execute:frappe.db.set_value(“Accounts Settings”, “Accounts Settings”, “unlink_payment_on_cancellation_of_invoice”, 0) in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.save_stock_settings in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.add_account_user_role_for_timesheet in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.update_invoice_status in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_0.po_status_issue_for_pr_return in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.update_missing_salary_component_type in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.rename_quality_inspection_field in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_0.update_autoname_field in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.update_bom_base_currency in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_0.update_status_of_po_so in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.set_budget_against_as_cost_center in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.set_currency_exchange_date in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.set_sales_person_status in erp.localhost (cfd511bd42)
Success
Executing erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items in erp.localhost (cfd511bd42)
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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, 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 716, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/frappe/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/frappe/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/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 210, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py”, line 44, in execute
repost_stock(item_code, warehouse)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/stock_balance.py”, line 41, in repost_stock
“reserved_qty”: get_reserved_qty(item_code, warehouse),
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/stock_balance.py”, line 108, in get_reserved_qty
“”", (item_code, warehouse, item_code, warehouse))
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 138, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, “Unknown column ‘stock_qty’ in ‘field list’”)
frappe@server:~/frappe-bench$

I did a search and some relevant topics came up:
Problem about purchase analysis

Do I need to do my own manual patching?

Hi @slushpuppy

Goto frappe-bench folder, run bench console and execute below code
frappe.reload_doctype(‘Sales Order’)
frappe.reload_doctype(‘Sales Invoice’)
frappe.reload_doctype(‘Quotation’)
frappe.reload_doctype(‘Delivery Note’)
frappe.db.commit()
exit

After this run command bench migrate

Hi @rohit_w

Thanks alot for sticking with me:

frappe@server:~/frappe-bench$ bench --site erp.localhost console
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
Type “copyright”, “credits” or “license” for more informa

IPython 4.2.0 – An enhanced Interactive Python.
? -> Introduction and overview of IPython’s featu
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for e

In [1]: frappe.reload_doctype(‘Sales Order’)

In [2]: frappe.reload_doctype(‘Sales Order’)

In [3]: frappe.reload_doctype(‘Quotation’)

In [4]: frappe.reload_doctype(‘Delivery Note’)

In [5]: frappe.db.commit()

In [6]: exit

frappe@server:~/frappe-bench$ bench --site erp.localhost migrate
Migrating erp.localhost
Executing erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items in erp.localhost (cfd511bd42)
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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, 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 716, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/frappe/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/frappe/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/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, 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 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 210, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py”, line 44, in execute
repost_stock(item_code, warehouse)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/stock_balance.py”, line 41, in repost_stock
“reserved_qty”: get_reserved_qty(item_code, warehouse),
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/stock_balance.py”, line 108, in get_reserved_qty
“”", (item_code, warehouse, item_code, warehouse))
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 138, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, “Unknown column ‘stock_qty’ in ‘field list’”)

We have fixed the issue, kindly pull latest update and check

Thanks alot @Rohit_w