Module import failed for Sales Invoice (erpnext.accounts.doctype.sales_invoice.sales_invoice)

Hi there!
I’m quite lost at the moment. When trying to upgrade erpnext from V6 to V7 I get the following error:

~/frappe-bench$ bench update --upgrade
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            develop    -> FETCH_HEAD
Already up-to-date.
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
Migrating site1.local
Executing finally:frappe.patches.v6_24.sync_desktop_icons in site1.local (1bd3e0294d)
Success
Executing frappe.patches.v7_2.set_in_standard_filter_property #1 in site1.local (1bd3e0294d)
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/dev/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/dev/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/dev/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/dev/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/dev/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/dev/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/dev/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/dev/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/commands/site.py", line 209, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/dev/frappe-bench/apps/frappe/frappe/migrate.py", line 30, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/dev/frappe-bench/apps/frappe/frappe/patches/v7_2/set_in_standard_filter_property.py", line 13, in execute
    frappe.reload_doctype(doctype.name, force=True)
  File "/home/dev/frappe-bench/apps/frappe/frappe/__init__.py", line 641, in reload_doctype
    force=force, reset_permissions=reset_permissions)
  File "/home/dev/frappe-bench/apps/frappe/frappe/__init__.py", line 653, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
  File "/home/dev/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/dev/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 19, in import_files
    reset_permissions=reset_permissions)
  File "/home/dev/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/dev/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 57, in import_file_by_path
    reset_permissions=reset_permissions)
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 125, in import_doc
    doc.insert()
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 212, in insert
    self.run_post_save_methods()
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 768, in run_post_save_methods
    self.run_method("on_update")
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 651, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 858, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 841, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 645, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 197, in on_update
    self.run_module_method("on_doctype_update")
  File "/home/dev/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 206, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "/home/dev/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 Sales Invoice (erpnext.accounts.doctype.sales_invoice.sales_invoice)

Any hints on where to start?

Cheers
Korbi

EDIT:
After bench switch-to-develop, running bench update without success and a switch back to master I get following output:

:~/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.
/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
Migrating site1.local
Executing finally:frappe.patches.v6_24.sync_desktop_icons in site1.local (1bd3e0294d)
Success
Executing erpnext.patches.v7_0.set_portal_settings in site1.local (1bd3e0294d)
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/dev/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/dev/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/dev/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/dev/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/dev/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/dev/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/dev/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/dev/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/commands/site.py", line 209, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/dev/frappe-bench/apps/frappe/frappe/migrate.py", line 30, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/dev/frappe-bench/apps/erpnext/erpnext/patches/v7_0/set_portal_settings.py", line 15, in execute
    frappe.get_doc('Portal Settings').sync_menu()
  File "/home/dev/frappe-bench/apps/frappe/frappe/website/doctype/portal_settings/portal_settings.py", line 32, in sync_menu
    frappe.get_doc({"doctype": "Role", "role_name": item.get('role'), "desk_access": 0}).insert()
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 206, in insert
    self.run_method("after_insert")
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 651, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 858, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 841, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 645, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/core/doctype/role/role.py", line 19, in after_insert
    user.add_roles(self.name)
  File "/home/dev/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 375, in add_roles
    self.save()
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 223, in save
    return self._save(*args, **kwargs)
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 268, in _save
    self.update_children()
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 286, in update_children
    self.update_child_table(df.fieldname, df)
  File "/home/dev/frappe-bench/apps/frappe/frappe/model/document.py", line 318, in update_child_table
    (self.name, self.doctype, fieldname))
  File "/home/dev/frappe-bench/apps/frappe/frappe/database.py", line 137, in sql
    self._cursor.execute(query, values)
  File "/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/dev/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1146, "Table '1bd3e0294d.tabUser Email' doesn't exist")

Back again - I solved it!
The upgrade seems to have had some problems and did not finish correctly.
After restoring my sql backup and re-running the update --upgrade command, everything went fine :slight_smile:

Thanks for your awesome work!
Cheers
Korbi

1 Like