ERPNext Conference 2019* ERPNext.com Blog

frappe.exceptions.ValidationError: Number <b>2347030441822</b> cannot be set as primary for Phone as well as Mobile No

installation_problem

#1

Hello all,
I just executed a bench restore with a backup file from an erpnext application which is currently in operation to another erpnext application on my vmware which I installed.

After running the --force restore command, I ran the bench migrate and I got this error.

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 228, in insert
self.run_before_save_methods()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 886, in run_before_save_methods
self.run_method(“validate”)
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/contacts/doctype/contact/contact.py”, line 35, in validate
self.check_if_primary_phone_and_mobile_no_same()
File “/home/interra/frappe-bench/apps/frappe/frappe/contacts/doctype/contact/contact.py”, line 125, in check_if_primary_phone_and_mobile_no_same
frappe.throw(
(“Number {0} cannot be set as primary for Phone as well as Mobile No.”).format(number))
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 360, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 346, in msgprint
_raise_exception()
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 315, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: Number 2347030441822 cannot be set as primary for Phone as well as Mobile No.

I will be grateful if anyone can render me any form of support so that I may be able to fix this error.

The reason why I embarked on this force restore was to see how I can restore a version 10 backup file to a freshly installed version 12 erpnext application which is running on my vmware. I’m still new and learning erpnext and will appreciate any form of support in resolving this error. Thank you.


#2

You need to identify the particular Contact that violates this validation rule, and delete the problem mobile phone # entry. Do this ideally from the UI client, otherwise you must access the database.


#3

That’s actually what I did. I went back to the site, traced where the number was registered, and then edited it. Thanks alot.