Could not find Default Item Group: Products

Hello,

I’m trying to update my installation from 9.1.2 ----> 9.2.2.
When I do bench update, it fails with:
frappe.exceptions.LinkValidationError: Could not find Default Item Group: Products

In effect, I have deleted the Group “Products” (I’m not using it). Anyway that I can fix this?

Thanks!

Can’t you add it back in?

I’m stuck on the update screen:
Updating
Your system is being updated. Please refresh again after a few moments

You mean you updated your production server without testing the update? You might want to change your update protocols.

Can you restore then add Products back into the Item Group Tree?

It’s just a test environment. Not in production yet. :wink:

LOL. That is a relief!

@AnthonyVV try this:

$ cd ~/frappe-bench/
$ bench --site sitename console

$ doc = frappe.new_doc("Item Group")
$ doc.update({
    "item_group_name": "Products",
    "parent_item_group": "All Item Groups",
    "is_group": 0
})

$ doc.insert()
$ frappe.db.commit() # commit your changes to the DB

It should be done from the server console. Let me know if anything goes wrong!

4 Likes

Thank you @yefritavarez! It worked! :smile:

Hi!,

I have the same error but with the Warehouse!.. Could you help me please ? i tried this but before the last part i have an error:

In [5]: doc.insert()

MandatoryError Traceback (most recent call last)
/frappe-bench/apps/frappe/frappe/commands/utils.pyc in ()
----> 1 doc.insert()

/frappe-bench/apps/frappe/frappe/model/document.pyc in insert(self, ignore_permissions, ignore_if_duplicate, ignore_mandatory)
217 self._validate_links()
218 self.run_before_save_methods()
→ 219 self._validate()
220 self.set_docstatus()
221 self.flags.in_insert = False

/frappe-bench/apps/frappe/frappe/model/document.pyc in _validate(self)
434
435 def _validate(self):
→ 436 self._validate_mandatory()
437 self._validate_selects()
438 self._validate_constants()

/frappe-bench/apps/frappe/frappe/model/document.pyc in _validate_mandatory(self)
653 fields=", ".join((each[0] for each in missing)),
654 doctype=self.doctype,
→ 655 name=self.name))
656
657 def _validate_links(self):

MandatoryError: [Warehouse, a9131d32cf]: warehouse_name, company

@yefritavarez could you help me please ?

Hi @gvargas,

You need to check what are the mandatory fields in the form.

It says that you’re missing two fields in the document. Fill them up with valid data and try again.

Thank you for answer me first of all.

i try this:

$ doc.update({
“item_group_name”: “Products”,
“parent_item_group”: “All Item Groups”,
“is_group”: 0
})

So… in the i put in this way this “item_group_name”: “Products”, → “item_group_name”: “Sucursales - VC”,

i don’t know if i need put in this way then: “item_group_name”: “Sucursales, VC”

do you agree ? i couldn’t view what are the mandatory field because i can’t run the erp it says “UPDATING”

I’m confused now.

Are you trying to add a new Item Group record or a Warehouse one @gvargas?

Hi @yefritavarez,

I also have the same problem while updating, the error is:
frappe.exceptions.LinkValidationError: Could not find Parent Item Group: All Item Groups.

When I try with the console, it replied with the same error.

Thank you

Sorry @yefritavarez, i try to explain me…

When i try to update this is the error that i had:

Migrating erp.local
Executing execute:frappe.get_single(‘Domain Settings’).save() in erp.local (c6d2cec0a2672282)
Traceback (most recent call last):
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/Developers/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/Developers/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/commands/site.py”, line 217, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/Developers/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
frappe.modules.patch_handler.run_all()
File “/Developers/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/Developers/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/Developers/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 81, in execute_patch
exec(patchmodule.split(“execute:”)[1],globals())
File “”, line 1, in
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 307, in _save
self.run_post_save_methods()
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 827, in run_post_save_methods
self.run_method(“on_update”)
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 964, in composer
return composed(self, method, *args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 947, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/core/doctype/domain_settings/domain_settings.py”, line 20, in on_update
domain.setup_domain()
File “/Developers/frappe-bench/apps/frappe/frappe/core/doctype/domain/domain.py”, line 20, in setup_domain
self.set_values()
File “/Developers/frappe-bench/apps/frappe/frappe/core/doctype/domain/domain.py”, line 74, in set_values
doc.save()
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 289, in _save
self._validate_links()
File “/Developers/frappe-bench/apps/frappe/frappe/model/document.py”, line 671, in _validate_links
frappe.LinkValidationError)
File “/Developers/frappe-bench/apps/frappe/frappe/init.py”, line 319, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/Developers/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/Developers/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
frappe.exceptions.LinkValidationError: Could not find Default Warehouse: Sucursales - VC

So trying to repeat your solution of the other error this is what happen:

MandatoryError: [Warehouse, a9131d32cf]: warehouse_name, company

and please ignore me last post is all wrong.

Thanks for the support

@gvargas, try this:

$ cd ~/frappe-bench/
$ bench --site sitename console

$ doc = frappe.new_doc("Warehouse")
$ doc.update({
    "warehouse_name": "Sucursales - VC",
    "company": [company_name],
    "is_group": 1
})

$ doc.insert()
$ frappe.db.commit() # commit your changes to the DB

@hokgt, see in your DB what is the name of your root Item Group.

Should be the one that does not have any parent.

Hi @yefritavarez,

I have access to the db and please refer the picture below:


The parrent is NULL

My question is:

  1. What is the parent of the root Item Group?
  2. There are two Item Groups that also don’t have parent, ie. Produk and Sub Assemblies, should I update those fields also?
  3. It is a bug from ERPNext? If it is, I will submit issue in github

Thank you

I suggest not to make any changes directly to the Database as it may introduce other bugs.

I’m guessing that if those three don’t have any parent is because the system needs them that way.

Anyways, try using this one:

$ cd ~/frappe-bench/
$ bench --site sitename console

$ doc = frappe.new_doc("Item Group")
$ doc.update({
    “item_group_name”: “All Item Groups”,
    “parent_item_group”: “Semua Grup Stok Barang/Item”, # or whatever that is
    “is_group”: 1
})

$ doc.save()
$ frappe.db.commit() # commit your changes to the DB
1 Like

Hi @yefritavarez ,

The last issue was solved but now same pattern except the variable is different:

frappe.exceptions.LinkValidationError: Could not find Default Unit of Measure: Unit

Could you explain how to find the which variable name should be updated? Then if the same error occured, I can find it myself.

Thank you

Well, I usually go to the DB and see the column names which will be the same as the fieldnames for the doc. Most of the time I find myself looking a the demo site to see what are the mandatory fields for a form and also to see if it already brings any default values, so that I don’t have to do it too.

1 Like