Migrate from V7 to V8

hi,
I’m trying to upgrade from v7 to v8 but restoring v7 backup on v8 install. SQL resotre complete and I can see the data in the tables but when running migrate I get the below trace

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 “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 91, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 17, 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 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, 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 1066, 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 895, 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 535, 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 216, 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_0/create_warehouse_nestedset.py”, line 29, in execute
make_warehouse_nestedset(company)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_0/create_warehouse_nestedset.py”, line 52, in make_warehouse_nestedset
validate_parent_account_for_warehouse(company)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_0/create_warehouse_nestedset.py”, line 76, in validate_parent_account_for_warehouse
if cint(erpnext.is_perpetual_inventory_enabled(company)):
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/init.py”, line 64, in is_perpetual_inventory_enabled
if not company in frappe.local.enable_perpetual_inventory:
TypeError: unhashable type: ‘_dict’

Hi @iadr3805

This issue has already fixed can you pull the latest code

Sorry for the screenshot but bench update is giving me the same error

It looks like it got broken here:

https://github.com/frappe/erpnext/commit/a5f40941ae43326c3222304adb5cd167dd923335#diff-c259c6ea5a16863022e8d316cb076be4R12

Should be as_dict=1, no?

Hi @iadr3805

Thanks for reporting an error, we have identified and fixed the issue and soon we’ll release the fix

I saw the fix was pushed couple of days a go, tried to bench update but getting below error

Executing erpnext.patches.v7_0.set_portal_settings in site1.local (1bd3e0294da19198)
/home/frappe/frappe-bench/apps/erpnext/erpnext/schools/doctype/assessment/assessment.json missing
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 “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 91, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 17, 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 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, 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 1066, 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 895, 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 535, 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 216, 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_0/set_portal_settings.py”, line 16, in execute
frappe.get_doc(‘Portal Settings’).sync_menu()
File “/home/frappe/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/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 182, in insert
self.set_defaults()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 493, in set_defaults
new_doc = frappe.new_doc(self.doctype, as_dict=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 595, in new_doc
return get_new_doc(doctype, parent_doc, parentfield, as_dict=as_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py”, line 19, in get_new_doc
frappe.local.new_doc_templates[doctype] = make_new_doc(doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py”, line 40, in make_new_doc
set_user_and_static_default_values(doc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py”, line 55, in set_user_and_static_default_values
user_default_value = get_user_default_value(df, defaults, user_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py”, line 70, in get_user_default_value
if (frappe.get_meta(df.options).document_type==“Setup”
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 636, in get_meta
return frappe.model.meta.get_meta(doctype, cached=cached)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py”, line 33, in get_meta
lambda: Meta(doctype))
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 173, in hget
value = generator()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py”, line 33, in
lambda: Meta(doctype))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py”, line 69, in init
super(Meta, self).init(“DocType”, doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 84, in init
self.load_from_db()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py”, line 74, in load_from_db
super(Meta, self).load_from_db()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 115, in load_from_db
frappe.throw(
(“{0} {1} not found”).format(
(self.doctype), self.name), frappe.DoesNotExistError)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 319, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
frappe.exceptions.DoesNotExistError: DocType Domain not found

@iadr3805,

Thanks for reporting fixed the issue via [minor] fixed the set_portal_settings patch by mbauskar · Pull Request #9890 · frappe/erpnext · GitHub

Thanks,
Makarand

1 Like

Hi guys,
Another error

Executing erpnext.patches.v8_0.update_stock_qty_value_in_bom_item in site1.local (1bd3e0294da19198)
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 “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 91, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 17, 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 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, 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 1066, 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 895, 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 535, 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 216, 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/v8_0/update_stock_qty_value_in_bom_item.py”, line 13, in execute
frappe.db.sql(“update tabBOM Scrap Item set stock_qty = qty”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 153, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 250, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 50, in defaulterrorhandler
raise errorvalue
_mysql_exceptions.OperationalError: (1054, “Unknown column ‘qty’ in ‘field list’”)

Any update on this?

@makarand_b, have you had time to look at the new error yet? Is it on my end or need a code fix?

@rohit_w
Hi guys, I’m still stuck on the upgrade path with the above error. Any update if it can be fixed on my end or needs a code fix.

@iadr3805

Are you made personal changes in a Doctype
and put a ‘qty’ column in to it, did not you?

“Unknown column ‘qty’ in ‘field list’”

Hope this helps.

You need to reload doc forcefully
https://github.com/frappe/erpnext/blob/develop/erpnext/patches/v8_0/update_stock_qty_value_in_bom_item.py#L8-L10

Also check

1 Like

I can’t figure out how to reload doc.
I followed the second link you provided and modified the file but then I get an error which is explained here, and these solution stashed the changes and same error appears.

The changes to the file need to take place after you run bench update and the files get downloaded from github, but before the patch runs. I’ve done this a few times where I have the modified file all ready to go, then after the first part of bench update runs (where the files all download from git), I override the patch with the one that is modified.

It takes a bit of timing, but is normally not too hard to do.

If I understand you correctly. run bench update, then upload the file with the changes during the update process? I’ve done this a few times and but no luck. Still getting the same error as above

mysqlexceptions.OperationalError: (1054, “Unknown column ‘qty’ in ‘field list’”)

this is the file I’m modifying

File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v8_0/update_stock_qty_value_in_bom_item.py”, line 13, in execute
frappe.db.sql(“update tabBOM Scrap Item set stock_qty = qty”)

Go to the console using bench --site <your-site-name> console and run following in console:

frappe.reload_doc('manufacturing', 'doctype', 'bom_item', force=True)
frappe.reload_doc('manufacturing', 'doctype', 'bom_explosion_item', force=True)
frappe.reload_doc('manufacturing', 'doctype', 'bom_scrap_item', force=True)
frappe.db.commit()

Exit from the console and run bench update again.

The commands run successfully

In [1]: frappe.reload_doc(‘manufacturing’, ‘doctype’, ‘bom_item’, force=True)
Out[1]: True

In [2]: frappe.reload_doc(‘manufacturing’, ‘doctype’, ‘bom_explosion_item’, force=True)
…:
Out[2]: True

In [3]: frappe.reload_doc(‘manufacturing’, ‘doctype’, ‘bom_scrap_item’, force=True)
Out[3]: True

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

But same error still there

Backing up sites…
Patching sites…
Migrating site1.local
Executing finally:erpnext.patches.v7_0.update_timesheet_communications in site1.local (1bd3e0294da19198)
Success
Executing erpnext.patches.v8_0.update_stock_qty_value_in_bom_item in site1.local (1bd3e0294da19198)
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 “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 91, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 17, 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 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, 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 1066, 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 895, 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 535, 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 216, 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/v8_0/update_stock_qty_value_in_bom_item.py”, line 13, in execute
frappe.db.sql(“update tabBOM Scrap Item set stock_qty = qty”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 165, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 250, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 50, in defaulterrorhandler
raise errorvalue
_mysql_exceptions.OperationalError: (1054, “Unknown column ‘qty’ in ‘field list’”)

Ok, I understood the issue, will push a fix soon. The problem is, in your case, “BOM Scrap Item” table is introducing for the first time and thats why there is no existing qty field.

Sent a PR to fix this, will be released soon.

https://github.com/frappe/erpnext/pull/10202