fix: check if 'All Item Group' exists before settings it as parent_item_group (#18956)
* fix: check if 'All Item Group' exists before settings it as parent_item_group * feat: get cached value to avoid db call on each insert
This commit is contained in:
parent
4726fc4893
commit
8e67a3a8a8
@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import copy
|
||||
from frappe import _
|
||||
from frappe.utils import nowdate, cint, cstr
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
from frappe.website.website_generator import WebsiteGenerator
|
||||
@ -28,7 +29,8 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
super(ItemGroup, self).validate()
|
||||
|
||||
if not self.parent_item_group and not frappe.flags.in_test:
|
||||
self.parent_item_group = 'All Item Groups'
|
||||
if frappe.db.exists("Item Group", _('All Item Groups'), cache=True):
|
||||
self.parent_item_group = _('All Item Groups')
|
||||
|
||||
self.make_route()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user