Is possible to import old database of erpnext v10 into newest erpnext version?

Hello everyone, I tried to import old database of erpnext v10 into newest erpnext version but no success. I follow 2 commands following to do that:

bench --force --site sitename restore /path/to/old/database
bench --force --site sitename migrate

Everything was ok when i have completed the first command. But after doing the second, error has ocurred:

Migrating erp.abx-ltd.com
Executing frappe.patches.v12_0.remove_deprecated_fields_from_doctype #3 in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.566s
Executing execute:frappe.reload_doc('core', 'doctype', 'comment') in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.172s
Executing execute:frappe.reload_doc('email', 'doctype', 'document_follow') in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.121s
Executing execute:frappe.reload_doc('core', 'doctype', 'communication_link') in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.125s
Executing execute:frappe.reload_doc('core', 'doctype', 'communication') in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.51s
Executing frappe.patches.v11_0.reload_and_rename_view_log #2019-01-03 in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.319s
Executing frappe.patches.v11_0.change_email_signature_fieldtype in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.577s
Executing frappe.patches.v11_0.rename_google_maps_doctype in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 1.565s
Executing frappe.patches.v10_0.modify_smallest_currency_fraction in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.024s
Executing frappe.patches.v10_0.modify_naming_series_table in erp.abx-ltd.com (_831804db5b8606b0)
Success: Done in 0.036s
Executing frappe.patches.v10_0.enhance_security in erp.abx-ltd.com (_831804db5b8606b0)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/frappe-erpnext/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/opt/frappe-erpnext/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/frappe-erpnext/.local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/commands/site.py", line 229, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/opt/frappe-erpnext/apps/frappe/frappe/migrate.py", line 48, in migrate
    frappe.modules.patch_handler.run_all()
  File "/opt/frappe-erpnext/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/opt/frappe-erpnext/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/opt/frappe-erpnext/apps/frappe/frappe/patches/v10_0/enhance_security.py", line 34, in execute
    doc.save()
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 271, in save
    return self._save(*args, **kwargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 307, in _save
    self.run_before_save_methods()
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 886, in run_before_save_methods
    self.run_method("validate")
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 786, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 1055, in composer
    return composed(self, method, *args, **kwargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 1038, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/opt/frappe-erpnext/apps/frappe/frappe/model/document.py", line 780, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/opt/frappe-erpnext/apps/frappe/frappe/core/doctype/system_settings/system_settings.py", line 39, in validate
    if (self.force_user_to_reset_password and
AttributeError: 'SystemSettings' object has no attribute 'force_user_to_reset_password'

Please tell me the solution to resolve that. Thank you.

1. reload the doctype system settings
bench  --site sitename console
frappe.reload_doc('core', 'doctype', 'system_settings')
exit

2. run migrate again
bench  --site sitename migrate

1 Like

I did the first command, but it had the following error:

In [1]: frappe.reload_doc('core', 'doctype', 'system_settings')
   ...:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/opt/frappe-erpnext/apps/frappe/frappe/commands/utils.pyc in <module>()
----> 1 frappe.reload_doc('core', 'doctype', 'system_settings')

/opt/frappe-erpnext/apps/frappe/frappe/__init__.pyc in reload_doc(module, dt, dn, force, reset_permissions)
    793
    794         import frappe.modules
--> 795         return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
    796
    797 def rename_doc(*args, **kwargs):

/opt/frappe-erpnext/apps/frappe/frappe/modules/utils.pyc in reload_doc(module, dt, dn, force, reset_permissions)
    172 def reload_doc(module, dt=None, dn=None, force=False, reset_permissions=False):
    173         from frappe.modules.import_file import import_files
--> 174         return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
    175
    176 def export_doc(doctype, name, module=None):

/opt/frappe-erpnext/apps/frappe/frappe/modules/import_file.pyc in import_files(module, dt, dn, force, pre_process, reset_permissions)
     25         else:
     26 		return import_file(module, dt, dn, force=force, pre_process=pre_process,
---> 27 			reset_permissions=reset_permissions)
     28
     29 def import_file(module, dt, dn, force=False, pre_process=None, reset_permissions=False):

/opt/frappe-erpnext/apps/frappe/frappe/modules/import_file.pyc in import_file(module, dt, dn, force, pre_process, reset_permissions)
     30         """Sync a file from txt if modifed, return false if not updated"""
     31         path = get_file_path(module, dt, dn)
---> 32         ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
     33         return ret
     34

/opt/frappe-erpnext/apps/frappe/frappe/modules/import_file.pyc in import_file_by_path(path, force, data_import, pre_process, ignore_version, reset_permissions, for_sync)
     64                         frappe.flags.in_import = True
     65 			import_doc(doc, force=force, data_import=data_import, pre_process=pre_process,
---> 66 				ignore_version=ignore_version, reset_permissions=reset_permissions)
     67                         frappe.flags.in_import = False
     68

/opt/frappe-erpnext/apps/frappe/frappe/modules/import_file.pyc in import_doc(docdict, force, data_import, pre_process, ignore_version, reset_permissions)
    139                 doc.flags.ignore_mandatory = True
    140
--> 141         doc.insert()
    142
    143         frappe.flags.in_import = False

/opt/frappe-erpnext/apps/frappe/frappe/model/document.pyc in insert(self, ignore_permissions, ignore_links, ignore_if_duplicate, ignore_mandatory)
    256                         self.copy_attachments_from_amended_from()
    257
--> 258                 self.run_post_save_methods()
    259                 self.flags.in_insert = False
    260

/opt/frappe-erpnext/apps/frappe/frappe/model/document.pyc in run_post_save_methods(self)
    925                         self.run_method("on_update_after_submit")
    926
--> 927                 self.run_method('on_change')
    928
    929                 self.clear_cache()

/opt/frappe-erpnext/apps/frappe/frappe/model/document.pyc in run_method(self, method, *args, **kwargs)
    784
    785                 fn.__name__ = str(method)
--> 786                 out = Document.hook(fn)(self, *args, **kwargs)
    787
    788                 self.run_notifications(method)

/opt/frappe-erpnext/apps/frappe/frappe/model/document.pyc in composer(self, *args, **kwargs)
   1053
   1054                         composed = compose(f, *hooks)
-> 1055                         return composed(self, method, *args, **kwargs)
   1056
   1057                 return composer

/opt/frappe-erpnext/apps/frappe/frappe/model/document.pyc in runner(self, method, *args, **kwargs)
   1038                                 add_to_return_value(self, fn(self, *args, **kwargs))
   1039                                 for f in hooks:
-> 1040                                         add_to_return_value(self, f(self, method, *args, **kwargs))
   1041
   1042                                 return self._return_value

/opt/frappe-erpnext/apps/frappe/frappe/social/doctype/energy_point_rule/energy_point_rule.pyc in process_energy_points(doc, state)
     49 	if (frappe.flags.in_patch
     50                 or frappe.flags.in_install
---> 51 		or not is_energy_point_enabled()):
     52                 return
     53

/opt/frappe-erpnext/apps/frappe/frappe/social/doctype/energy_point_settings/energy_point_settings.pyc in is_energy_point_enabled()
     13
     14 def is_energy_point_enabled():
---> 15         return frappe.get_cached_value('Energy Point Settings', None, 'enabled')
     16
     17 def allocate_review_points():

/opt/frappe-erpnext/apps/frappe/frappe/__init__.pyc in get_cached_value(doctype, name, fieldname, as_dict)
    700
    701 def get_cached_value(doctype, name, fieldname, as_dict=False):
--> 702         doc = get_cached_doc(doctype, name)
    703         if isinstance(fieldname, string_types):
    704                 if as_dict:

/opt/frappe-erpnext/apps/frappe/frappe/__init__.pyc in get_cached_doc(*args, **kwargs)
    685
    686         # database
--> 687         doc = get_doc(*args, **kwargs)
    688
    689         return doc

/opt/frappe-erpnext/apps/frappe/frappe/__init__.pyc in get_doc(*args, **kwargs)
    728 	"""
    729         import frappe.model.document
--> 730         doc = frappe.model.document.get_doc(*args, **kwargs)
    731
    732         # set in cache

/opt/frappe-erpnext/apps/frappe/frappe/model/document.pyc in get_doc(*args, **kwargs)
     65                         raise ValueError('"doctype" is a required key')
     66
---> 67         controller = get_controller(doctype)
     68         if controller:
     69                 return controller(*args, **kwargs)

/opt/frappe-erpnext/apps/frappe/frappe/model/base_document.pyc in get_controller(doctype)
     40                         _class = Document
     41                 else:
---> 42                         module = load_doctype_module(doctype, module_name)
     43                         classname = doctype.replace(" ", "").replace("-", "")
     44                         if hasattr(module, classname):

/opt/frappe-erpnext/apps/frappe/frappe/modules/utils.pyc in load_doctype_module(doctype, module, prefix, suffix)
    204                         doctype_python_modules[key] = frappe.get_module(module_name)
    205         except ImportError as e:
--> 206                 raise ImportError('Module import failed for {0} ({1})'.format(doctype, module_name + ' Error: ' + str(e)))
    207
    208         return doctype_python_modules[key]

ImportError: Module import failed for Energy Point Settings (frappe.core.doctype.energy_point_settings.energy_point_settings Error: No module named energy_point_settings.energy_point_settings)

In [2]:

Thank you for your reply

Why not install a v10 setup, import the data, and then upgrade/migrate?

Ya, I thought it before and i tried to do it. But no success. I couldn’t install certain erpnext version i want and there some errors during installation. have you do it? Can you please tell me the instruction about this? Thank you.

You can specify erpnext v10.x.x in the easy install script, or you can modify your existing install by using the v10.x.x in the bench update lines.
See this post

1 Like

after doing

sudo python install.py --production --user frappe --frappe-branch v11.x.x-develop --erpnext-branch v10.x.x

i had issuer below

TASK [bench : Create a new site] *****************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["bench", "new-site", "site1.local", "--admin-password", "fiisoft", "--mariadb-root-password", "lengoccan"], "delta": "0:00:00.273003", "end": "2019-06-17 12:10:55.433119", "msg": "non-zero return code", "rc": 2, "start": "2019-06-17 12:10:55.160116", "stderr": "Usage: bench [OPTIONS] COMMAND [ARGS]...\nTry \"bench --help\" for help.\n\nError: No such command \"new-site\".", "stderr_lines": ["Usage: bench [OPTIONS] COMMAND [ARGS]...", "Try \"bench --help\" for help.", "", "Error: No such command \"new-site\"."], "stdout": "", "stdout_lines": []}

PLAY RECAP ***************************************************************************************
localhost                  : ok=50   changed=9    unreachable=0    failed=1    skipped=71   rescued=0    ignored=0

Traceback (most recent call last):
  File "install.py", line 432, in <module>
    install_bench(args)
  File "install.py", line 128, in install_bench
    run_playbook('site.yml', sudo=True, extra_vars=extra_vars)
  File "install.py", line 344, in run_playbook
    success = subprocess.check_call(args, cwd=os.path.join(cwd, 'playbooks'))
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-e', '@/tmp/extra_vars.json', '--become', '--become-user=frappe']' returned non-zero exit status 2

Why have you chosen v10 for erpnext and v11-dev for frappe?
It would be better to use v10-production for both in your initial setup to import the data, and then consider migrating to v11 once you have it working with your old data/restore

Ya. I tried both, but it has same issue above

Does anyone can help me resolve? I tried to fix this error so much, But there was no progress. Thank you.