(Resolved) Restore V12 from V10 backups

The json model file defines each doctype’s table schema, say for eg tabAccount

I believe no specific record is kept whether a patch has been applied, or any mechanism prevents a patch that has been already applied from being reapplied.

Hence the problem case when a table changes names - the repeat migration errors out since the patch fails to find the original table to rename again.

edit: where a patch renames a DocType - on a repeat run, the patch simply returns, only on the first run does it perform all the housekeeping changes from the onlt to the new doctype - here’s the code

Thank to all that contributed to this topic, and a special note to @Zlash65.

This is how I solved the problem.

On my old server (running erpnext 10.1.81)

$ cd erpnext
$ bench backup 
$ bench backup --with files 

On the new server (runnng erpnext 12.x.x-develop)

   $ cd erpnext
   $ bench --force restore --with-public-files backups/20190228_173601-erp_mysite-files.tar --with-private-files backups/20190228_173601-erp_mysite-private-files.tar  backups/20190228_173601-erp_mysite-database.sql.gz
   $ bench start

On the new server (in a new tab, while bench was started in a previous tab)

$ bench --site erp.mysite migrate

5 Likes

Correction: ok my error in fact the Patch Log Doctype records this -

Here is the relevant patch code frappe/frappe/modules/patch_handler.py at develop · frappe/frappe · GitHub

This lists the last 10 patches applied in my instance:

MariaDB [1bd3e0294da19198]> select name,patch from `tabPatch Log` order by name desc limit 10;
+---------------+----------------------------------------------------------------------------+
| name          | patch                                                                      |
+---------------+----------------------------------------------------------------------------+
| PATCHLOG00824 | execute:frappe.delete_doc('DocType', 'Notification Control')               |
| PATCHLOG00823 | erpnext.patches.v11_1.setup_guardian_role                                  |
| PATCHLOG00822 | erpnext.patches.v11_0.add_permissions_in_gst_settings                      |
| PATCHLOG00821 | erpnext.patches.v11_0.renamed_from_to_fields_in_project                    |
| PATCHLOG00820 | erpnext.patches.v11_0.rename_additional_salary_component_additional_salary |
| PATCHLOG00819 | erpnext.patches.v11_0.rename_bom_wo_fields                                 |
| PATCHLOG00818 | erpnext.patches.v11_0.set_missing_gst_hsn_code                             |
| PATCHLOG00817 | erpnext.patches.v11_0.update_delivery_trip_status                          |
| PATCHLOG00816 | erpnext.patches.v10_0.allow_operators_in_supplier_scorecard                |
| PATCHLOG00815 | erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items |
+---------------+----------------------------------------------------------------------------+
10 rows in set (0.00 sec)

As noted in the Updating section here GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps

bench update --patch will only run database migrations in the apps

These list the patches in effect for each app:

frappe@ubuntu:~/frappe-bench$ find . -name patches.txt
./patches.txt
./apps/erpnext/erpnext/patches.txt
./apps/frappe/frappe/patches.txt

can you detail explain the method1

I did method 2:

and I got this when I run bench migrate

Migrating site1.local
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", lin                                                                                       e 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", lin                                                                                       e 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py"                                                                                       , line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py"                                                                                       , line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py"                                                                                       , line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py"                                                                                       , line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py"                                                                                       , line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py"                                                                                       , line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/decorato                                                                                       rs.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 45, in mi                                                                                       grate
    frappe.get_attr(fn)()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v11_0/sync_user_per                                                                                       mission_doctype_before_migrate.py", line 6, in execute
    frappe.reload_doc('core', 'doctype', 'user_permission')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 799, in                                                                                        reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissi                                                                                       ons=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 174                                                                                       , in reload_doc
    return import_files(module, dt, dn, force=force, reset_permissions=reset_per                                                                                       missions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", li                                                                                       ne 27, in import_files
    reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", li                                                                                       ne 32, in import_file
    ret = import_file_by_path(path, force, pre_process=pre_process, reset_permis                                                                                       sions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", li                                                                                       ne 66, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", li                                                                                       ne 141, in import_doc
    doc.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 25                                                                                       8, in insert
    self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 91                                                                                       7, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 78                                                                                       6, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 10                                                                                       56, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 10                                                                                       41, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/automation/doctype/mileston                                                                                       e_tracker/milestone_tracker.py", line 34, in evaluate_milestone
    dict(document_type = doc.doctype, disabled=0)):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/cache_manager.py", line 107                                                                                       , in get_doctype_map
    items = frappe.get_all(doctype, filters=filters, order_by = order_by)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1299, in                                                                                        get_all
    return get_list(doctype, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1272, in                                                                                        get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **k                                                                                       wargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 95                                                                                       , in execute
    result = self.build_and_run()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 10                                                                                       9, in build_and_run
    args = self.prepare_args()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 13                                                                                       6, in prepare_args
    self.build_conditions()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 32                                                                                       4, in build_conditions
    self.build_filter_conditions(self.filters, self.conditions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 34                                                                                       5, in build_filter_conditions
    conditions.append(self.prepare_filter_condition(f))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 35                                                                                       2, in prepare_filter_condition
    f = get_filter(self.doctype, f)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py", line 898, i                                                                                       n get_filter
    meta = frappe.get_meta(f.doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 759, in                                                                                        get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py", line 37, in                                                                                        get_meta
    meta = Meta(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py", line 84, in                                                                                        __init__
    super(Meta, self).__init__("DocType", doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 10                                                                                       4, in __init__
    self.load_from_db()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py", line 89, in                                                                                        load_from_db
    super(Meta, self).load_from_db()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 14                                                                                       7, in load_from_db
    frappe.throw(_("{0} {1} not found").format(_(self.doctype), self.name), frap                                                                                       pe.DoesNotExistError)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 360, in                                                                                        throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 346, in                                                                                        msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 315, in                                                                                        _raise_exception
    raise raise_exception(msg)
frappe.exceptions.DoesNotExistError: DocType Milestone Tracker not found

I tried this from here Upgrading V11- V12 Milestone tracker doctype not found but the issue is still there.

Any recomendations?

In the fresh server I saw that frappe version and erpnext version aren’t the same.

image
then I run
sudo bench switch-to-branch version-12 --upgrade

and got both in version-12

I run this
bench reload-doc Core Doctype milestone_tracker
but I got this message

/apps/frappe/frappe/core/doctype/milestone_tracker/milestone_tracker.json missing

I dunno what else to do.
Any one with a suggestion?

That doctype lives in automation not core - say a code refactoring switched its location stored on the file system?
frappe/frappe/automation/doctype/milestone_tracker at develop · frappe/frappe · GitHub

I have no v12 instance to check but why not try this:

bench reload-doc automation doctype milestone_tracker

2 Likes

Yes, actually @clarkej is right, I can confirm it.
I just checked on a v12 instance that i have and where he pointed to the json file is there in automation. The exact path:
/apps/frappe/frappe/automation/doctype/milestone_tracker/milestone_tracker.json

1 Like

Thanks, it worked.! but I still have a question. Why it this happening? and how can I avoid that. because, that’s a fresh server, those DocTypes must be in there rigth?

Well, migrate runs and applies any current patches once and only once. A given patch assumes and can change how a DocType is defined; when that version definition as stored in memory differs from its table schema defined in the database, the two are out of sync - this mismatch results in error tracebacks.

My guess is out of sync cases can arise where some later patch is applied that operates on a ‘stale’ DocType from an earlier defined version. In that case one must manually reload the DocType to its current version?

I can’t say how you avoid this - to identify and fix patch issues? Frappe and the community try hard to address such problems…

edit: These may help to get more sense here:
https://support.erpnext.com/docs/user/en/tutorial/models

1 Like

Hello I ran the Method 2, this is what I got.

Migrating site1.local
Executing frappe.patches.v12_0.remove_deprecated_fields_from_doctype #3 in site1.local (_1bd3e0294da19198)
Success: Done in 1.255s
Executing frappe.patches.v11_0.drop_column_apply_user_permissions in site1.local (_1bd3e0294da19198)
Success: Done in 1.327s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2018-02-20 in site1.local (_1bd3e0294da19198)
Success: Done in 1.757s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docperm’) #2018-05-29 in site1.local (_1bd3e0294da19198)
Success: Done in 0.051s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘comment’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.528s
Executing execute:frappe.reload_doc(‘email’, ‘doctype’, ‘document_follow’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.655s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘communication_link’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.269s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘communication’) in site1.local (_1bd3e0294da19198)
Success: Done in 1.364s
Executing frappe.patches.v11_0.replicate_old_user_permissions in site1.local (_1bd3e0294da19198)
Success: Done in 24.126s
Executing frappe.patches.v11_0.reload_and_rename_view_log #2019-01-03 in site1.local (_1bd3e0294da19198)
Success: Done in 0.268s
Executing frappe.patches.v11_0.copy_fetch_data_from_options in site1.local (_1bd3e0294da19198)
Success: Done in 3.261s
Executing frappe.patches.v11_0.change_email_signature_fieldtype in site1.local (_1bd3e0294da19198)
Success: Done in 1.289s
Executing frappe.patches.v10_0.refactor_social_login_keys in site1.local (_1bd3e0294da19198)
Success: Done in 2.006s
Executing frappe.patches.v10_0.enable_chat_by_default_within_system_settings in site1.local (_1bd3e0294da19198)
Success: Done in 3.679s
Executing frappe.patches.v10_0.remove_custom_field_for_disabled_domain in site1.local (_1bd3e0294da19198)
Success: Done in 0.571s
Executing execute:frappe.delete_doc(“Page”, “chat”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.495s
Executing frappe.patches.v10_0.migrate_passwords_passlib in site1.local (_1bd3e0294da19198)
Success: Done in 3.234s
Executing frappe.patches.v11_0.rename_standard_reply_to_email_template in site1.local (_1bd3e0294da19198)
Success: Done in 0.131s
Executing execute:frappe.delete_doc_if_exists(‘Page’, ‘user-permissions’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.051s
Executing frappe.patches.v11_0.create_contact_for_user in site1.local (_1bd3e0294da19198)
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/interra/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/interra/frappe-bench/apps/frappe/frappe/migrate.py”, line 48, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/interra/frappe-bench/apps/frappe/frappe/patches/v11_0/create_contact_for_user.py”, line 23, in execute
create_contact(user, ignore_links=True, ignore_mandatory=True)
File “/home/interra/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 1047, in create_contact
contact.insert(ignore_permissions=True, ignore_links=ignore_links, ignore_mandatory=ignore_mandatory)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 252, in insert
self.run_method(“after_insert”)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 786, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1056, in composer
return composed(self, method, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1041, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/interra/frappe-bench/apps/erpnext/erpnext/communication/doctype/call_log/call_log.py”, line 89, in set_caller_information
logs = frappe.get_all(‘Call Log’, filters=filters)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 1299, in get_all
return get_list(doctype, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 1272, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 95, in execute
result = self.build_and_run()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 109, in build_and_run
args = self.prepare_args()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 135, in prepare_args
self.set_optional_columns()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 293, in set_optional_columns
columns = frappe.db.get_table_columns(self.doctype)
File “/home/interra/frappe-bench/apps/frappe/frappe/database/database.py”, line 857, in get_table_columns
raise self.TableMissingError
pymysql.err.ProgrammingError

Please can you assist in resolving this? Thank you.

If you run an update the code now lists the name of the missing table -

You stack trace suggests Call Log is missing?

See if this helps:

bench reload-doc communication doctype call_log

Hello @clarkej
Thanks for your respnonse. After running bench reload-doc communication doctype call_log this is what I am getting;

Traceback (most recent call last):
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 204, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 808, in get_module
return importlib.import_module(modulename)
File “/home/interra/frappe-bench/env/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 941, in _find_and_load_unlocked
File “”, line 219, in _call_with_frames_removed
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘frappe.core.doctype.energy_point_settings’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/site.py”, line 265, in reload_doc
frappe.reload_doc(module, doctype, docname, force=context.force)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 799, in reload_doc
return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 174, in reload_doc
return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 27, in import_files
reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 32, in import_file
ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 66, in import_file_by_path
ignore_version=ignore_version, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 141, in import_doc
doc.insert()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 258, in insert
self.run_post_save_methods()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 917, in run_post_save_methods
self.run_method(“on_update”)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 786, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1056, in composer
return composed(self, method, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1039, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 780, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 284, in on_update
make_module_and_roles(self)
File “/home/interra/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 1119, in make_module_and_roles
m.insert()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 258, in insert
self.run_post_save_methods()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 927, in run_post_save_methods
self.run_method(‘on_change’)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 786, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1056, in composer
return composed(self, method, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1041, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/interra/frappe-bench/apps/frappe/frappe/social/doctype/energy_point_rule/energy_point_rule.py”, line 85, in process_energy_points
or not is_energy_point_enabled()):
File “/home/interra/frappe-bench/apps/frappe/frappe/social/doctype/energy_point_settings/energy_point_settings.py”, line 15, in is_energy_point_enabled
return frappe.get_cached_value(‘Energy Point Settings’, None, ‘enabled’)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 706, in get_cached_value
doc = get_cached_doc(doctype, name)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 691, in get_cached_doc
doc = get_doc(*args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 734, in get_doc
doc = frappe.model.document.get_doc(*args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 67, in get_doc
controller = get_controller(doctype)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 47, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 206, in load_doctype_module
raise ImportError(‘Module import failed for {0} ({1})’.format(doctype, module_name + ’ Error: ’ + str(e)))
ImportError: Module import failed for Energy Point Settings (frappe.core.doctype.energy_point_settings.energy_point_settings Error: No module named ‘frappe.core.doctype.energy_point_settings’)

Please is there any other command I can run to resolve this error? Thanks for your support.

ok what to do here for clues and pointers to proceed, try this -

  1. search up ‘ImportError: Module import failed for’

  2. apply that q&a advice in your case here for the ‘Energy Point Settings’ module

You may also want to start a new thread for further tips and advice

@clarkej Thanks for your support, I’ll do as you say.

Ok this is what I have found out from the last error I encountered. I temporarily cleared all patches on frappe and erpnext by going to apps/frappe/frappe/patches.txt from my frappe-bench directory and apps/erpnext/erpnext/patches.txt. I ran bench migrate which restored the database. After which I ran bench update --reset.

This cleared the ImportError I posted as my last snag. However, I am encountering another snag which I am hoping someone might help me with a clue in resolving the error.

This is the traceback I am having;

Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/interra/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/interra/frappe-bench/apps/frappe/frappe/migrate.py”, line 48, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/interra/frappe-bench/apps/erpnext/erpnext/patches/v11_0/rename_production_order_to_work_order.py”, line 10, in execute
rename_doc(‘DocType’, ‘Production Order’, ‘Work Order’, force=True)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/rename_doc.py”, line 43, in rename_doc
rename_parent_and_child(doctype, old, new, meta)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/rename_doc.py”, line 138, in rename_parent_and_child
frappe.db.sql(“UPDATE tab{0} SET name={1} WHERE name={1}”.format(doctype, ‘%s’), (new, old))
File “/home/interra/frappe-bench/apps/frappe/frappe/database/database.py”, line 156, in sql
self._cursor.execute(query, values)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, “Duplicate entry ‘Work Order’ for key ‘PRIMARY’”)

I would be grateful for any contribution in resolving this error. Thank you.

Hello,
does anyone has any clue to resolving this error?

Which version are you on. The logs seem to indicate version 11, while you say you should be on 12.

Hello @crafter,
I’m running erpnext v12 on my VM.

Hi again, Can you explain the reload-doc command, because I run it and it worked, but when I restore another site in the same erpnext instance, the console throws the same error, and I though that document was in there already when I run that command,

that command download the doctype file in the server again? o…?

thanks in advance