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

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


cd ~/frappe-bench
bench update

update to major release ex. v12 → v13

nodejs >= 10 required

cd ~
curl -sL -o
sudo bash
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/”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/”, line 85, in _run_code
exec(code, run_globals)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 99, in
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 18, in main
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/”, 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/”, 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/”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/”, line 26, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/”, line 296, in migrate
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 67, in migrate
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 41, in run_all
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/frappe/frappe/patches/v12_0/”, line 39, in execute
frappe.set_value(‘User’,, ‘home_settings’, home_settings)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 746, in set_value
return frappe.client.set_value(doctype, docname, fieldname, value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 141, in set_value
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 285, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 320, in _save
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 950, in run_before_save_methods
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 848, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 1137, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 1120, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 842, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/”, line 78, in validate
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/”, 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

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:

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.!!!


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')