mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 23:18:40 +00:00
fix: resolve Item Group tree root structurally
A name lookup misses roots created under a translated name (pre-#49875 setups) or renamed roots. Resolve the first parentless group by lft and guard against self-parenting when the root itself is saved.
This commit is contained in:
@@ -32,8 +32,11 @@ class ItemGroup(NestedSet):
|
||||
|
||||
def validate(self):
|
||||
if not self.parent_item_group and not frappe.in_test:
|
||||
if frappe.db.exists("Item Group", "All Item Groups"):
|
||||
self.parent_item_group = "All Item Groups"
|
||||
root = frappe.db.get_value(
|
||||
"Item Group", {"parent_item_group": ("is", "not set"), "is_group": 1}, order_by="lft asc"
|
||||
)
|
||||
if root and root != self.name:
|
||||
self.parent_item_group = root
|
||||
self.validate_item_group_defaults()
|
||||
self.check_item_tax()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user