Update error in frappe.get_single('Domain Settings').save()

Hi, When I try to update get this error and I can’t figure out where is the problem:

  Backing up sites...
    Patching sites...
    Migrating demo
    Executing execute:frappe.get_single('Domain Settings').save() in demo (demo)
    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/erp/erpnext/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
      File "/home/erp/erpnext/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
      File "/home/erp/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
      File "/home/erp/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
      File "/home/erp/erpnext/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/erp/erpnext/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/erp/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
      File "/home/erp/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
      File "/home/erp/erpnext/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
      File "/home/erp/erpnext/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
      File "/home/erp/erpnext/apps/frappe/frappe/commands/site.py", line 217, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
      File "/home/erp/erpnext/apps/frappe/frappe/migrate.py", line 31, in migrate
      File "/home/erp/erpnext/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
      File "/home/erp/erpnext/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
      File "/home/erp/erpnext/apps/frappe/frappe/modules/patch_handler.py", line 81, in execute_patch
      File "<string>", line 1, in <module>
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 256, in save
    return self._save(*args, **kwargs)
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 307, in _save
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 827, in run_post_save_methods
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 702, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 964, in composer
    return composed(self, method, *args, **kwargs)
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 947, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 696, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
      File "/home/erp/erpnext/apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py", line 20, in on_update
      File "/home/erp/erpnext/apps/frappe/frappe/core/doctype/domain/domain.py", line 32, in setup_domain
      File "/home/erp/erpnext/apps/erpnext/erpnext/healthcare/setup.py", line 15, in setup_healthcare
      File "/home/erp/erpnext/apps/erpnext/erpnext/healthcare/setup.py", line 183, in create_healthcare_item_groups
      File "/home/erp/erpnext/apps/erpnext/erpnext/healthcare/setup.py", line 268, in insert_record
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 217, in insert
      File "/home/erp/erpnext/apps/frappe/frappe/model/document.py", line 671, in _validate_links
      File "/home/erp/erpnext/apps/frappe/frappe/__init__.py", line 319, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
      File "/home/erp/erpnext/apps/frappe/frappe/__init__.py", line 309, in msgprint
      File "/home/erp/erpnext/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
    raise raise_exception(encode(msg))
    frappe.exceptions.LinkValidationError: Could not find Parent Item Group: All Item Groups

Did you delete anything from the database ?? Its clearly visible that “All Item Groups” is not being found - the only way I see that happening is if its being meddled from the database :thinking:

You need to check for defaults and deleted docs …

have a look at:

Maybe you can try this from terminal and see if it works…

cd ~/frappe-bench/
bench --site site_name console
doc = frappe.new_doc("Item Group")
    "item_group_name": "All Item Groups",
    "is_group": 1

frappe.db.commit() # committing changes to database

Thanks @Zlash65 and @JoEz for the answers.
I have the follow item groups in the database:

frappe.get_all("Item Group")
[{'name': u'Varios'},
 {'name': u'Todos los Grupos de Art\xedculos'},
 {'name': u'USB'},
 {'name': u'Sub-Ensamblajes'},
 {'name': u'Servicios'},
 {'name': u'Productos'},
 {'name': u'Materia prima'},
 {'name': u'Consumible'},
 {'name': u'Modulares'},
 {'name': u'Oficina'},
 {'name': u'Cocina'}]

In which u’Todos los Grupos de Art\xedculos’ is the ‘All Item Groups’ translated in my language.
I’will try your solution however.


Maybe thats what the issue is :thinking:
bench while migrating is searching for “All Item Groups” instead of the translated version of it…

Just checked - https://translate.erpnext.com/view?lang=es&search=All%20Item%20Groups
Your version of translation seems to be different and hence could be causing the issue

Instead of the above code, try this inside bench console [ experimental - hope this is a demo site ]

frappe.db.sql("update `tabItem Group` set name='Todos los Grupos de Artículos' where name='Todos los Grupos de Art\xedculos'")

@Zlash65 I updated the Item Group as you suggested and now the migration works.
Thanks for your time!