Skip to content

fix: seed standard Item Groups under the existing tree root (backport #57616) - #57629

Merged
mihir-kandoi merged 2 commits into
version-15-hotfixfrom
mergify/bp/version-15-hotfix/pr-57616
Jul 30, 2026
Merged

fix: seed standard Item Groups under the existing tree root (backport #57616)#57629
mihir-kandoi merged 2 commits into
version-15-hotfixfrom
mergify/bp/version-15-hotfix/pr-57616

Conversation

@mergify

@mergify mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Closes #57581

install_fixtures always inserted "All Item Groups" as a parentless group. When the tree already had a root, ItemGroup.validate re-parented it, leaving a second group-root holding the standard groups while the real root held everything else.

Reproducible with the healthcare app on a non-English site: its after_install seeds the root as _("All Item Groups"), so a pt-BR site gets Todos os Grupos de Itens as the root before the setup wizard runs.

'Todos os Grupos de Itens' <- ''        (root)
  'Laboratory', 'Drug'
  'All Item Groups' (is_group=1)
    'Products', 'Raw Material', 'Services', 'Sub Assemblies', 'Consumable'

This predates #57390 — I reproduced it with the old translated-name lookup restored and got an identical tree, since _("All Item Groups") resolved to the same root. (The healthcare side is a separate bug: it should seed the untranslated name like install_fixtures does.)

Resolve the root once with get_root_of, falling back to the canonical English name on fresh installs, and use it for the root record's exists-guard and the standard groups' parent — same as Company.create_default_departments.

The patch merges an already-seeded "All Item Groups" into the root it sits under, lifting its children and repointing every link. It only fires when that node is a group whose parent is exactly the current root, and is a no-op on re-run.


This is an automatic backport of pull request #57616 done by Mergify.

install_fixtures always inserted "All Item Groups" as a parentless group.
On a site where another app had already created the root, ItemGroup.validate
re-parented it, leaving a second group-root that held the standard groups
while the real root held everything else.

This is reproducible with the healthcare app on a non-English site: its
after_install seeds the root as _("All Item Groups"), so a pt-BR site gets
"Todos os Grupos de Itens" as the root before the setup wizard runs. The
split predates #57390 -- the old translated-name lookup resolved to the same
root and produced an identical tree.

Resolve the root once with get_root_of (falling back to the canonical English
name on fresh installs) and use it for the root record's exists-guard and the
standard groups' parent, matching Company.create_default_departments.

Patch merges an already-seeded "All Item Groups" into the root it sits under,
lifting its children and repointing every link.

Closes #57581

(cherry picked from commit e7088d8)

# Conflicts:
#	erpnext/setup/doctype/item_group/test_item_group.py
#	erpnext/setup/setup_wizard/operations/install_fixtures.py
@mergify
mergify Bot requested a review from ruthra-kumar as a code owner July 30, 2026 13:41
@mergify mergify Bot added the conflicts label Jul 30, 2026
@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of e7088d8 has failed:

On branch mergify/bp/version-15-hotfix/pr-57616
Your branch is up to date with 'origin/version-15-hotfix'.

You are currently cherry-picking commit e7088d8981.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   erpnext/patches.txt
	new file:   erpnext/patches/v16_0/merge_seeded_item_group_root.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   erpnext/setup/doctype/item_group/test_item_group.py
	both modified:   erpnext/setup/setup_wizard/operations/install_fixtures.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

install() holds the preset list inline on this branch, so the root is
resolved there instead of in get_preset_records. Dropping the preset-record
test with it -- there is no seam to call without running the whole installer.

The patch test is adapted to this branch: TestItem does not roll back between
tests, so it restores the original root name, and it passes parent_item_group
explicitly since ItemGroup.validate skips root-defaulting under
frappe.flags.in_test.
@mihir-kandoi
mihir-kandoi enabled auto-merge July 30, 2026 13:52
@mihir-kandoi
mihir-kandoi merged commit f2ec60b into version-15-hotfix Jul 30, 2026
16 checks passed
@mihir-kandoi
mihir-kandoi deleted the mergify/bp/version-15-hotfix/pr-57616 branch July 30, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant