Error While Upgrading to v13 from v12 AttributeError: 'User' object has no attribute 'module_profile'`Preformatted text`

Hello,
I am trying to upgrade erpnext from v12 to v13. I took the following steps:

update

cd ~/frappe-bench
bench update

update to major release ex. v12 → v13

nodejs >= 10 required

cd ~
curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
nodejs -v

now upgrade

cd ~/frappe-bench
bench switch-to-branch version-13-beta frappe erpnext --upgrade

after this I did:
bench update --patch and I get the following error:
Executing frappe.patches.v12_0.fix_home_settings_for_all_users 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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 99, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 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/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 26, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 296, in migrate
skip_search_index=skip_search_index
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 67, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/frappe/frappe/patches/v12_0/fix_home_settings_for_all_users.py”, line 39, in execute
frappe.set_value(‘User’, user.name, ‘home_settings’, home_settings)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 746, in set_value
return frappe.client.set_value(doctype, docname, fieldname, value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/client.py”, line 141, in set_value
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 285, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 320, in _save
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 950, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 848, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1137, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1120, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 842, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 78, in validate
self.validate_allowed_modules()
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 94, in validate_allowed_modules
if self.module_profile:
AttributeError: ‘User’ object has no attribute 'module_profile’Preformatted text

Create one module profile and save user then try. I am not sure but this is my guess.

I cannot open my ERPNext webpage it says internal server error

It sets back to base installed apps.

bench update --reset

Hi,
I am facing below issue
attributeerror: ‘user’ object has no attribute ‘module profile’ at the time of migrate

can anyone help

Just stumbled over this error at a customers site.

Seems like patches for v13 are executed before doctype creations/migrations are applied, which are necessary for those patches.

I worked around it by:

comment out 2 patches in apps/frappe/frappe/patches.txt:

frappe.core.doctype.role.patches.v13_set_default_desk_properties
execute:frappe.get_doc(‘Role’, ‘Guest’).save() # remove desk access

edit apps/frappe/frappe/core/doctype/user/user.json and set the modified date to a newer date, for example

“modified”: "2021-11-18 16:56:05.578379“

run bench migrate

activate the two patches in apps/frappe/frappe/patches.txt:

run bench migrate again.

Missing patches should be applied.

One should also be able to use “bench migrate --skip-failing” , but somehow, this did not work for me.

also working:

edit apps/frappe/frappe/core/doctype/user/user.json and set the modified date to a newer date, for example “modified”: "2021-11-18 16:56:05.578379“

bench migrate --skip-failing

and then again:

bench migrate

Hi Heti,
How did you solve this issue? I’m facing the same issue.!!!

Regards,
Mark

i faced similar issues for a few other doctypes while running
bench update --patch for upgrading to v13 from v12

the issues were gone when i reload the doctype on the bench console as follows.
frappe.reload_doc('core', 'doctype', 'user')
frappe.db.commit()