mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-17 00:25:01 +00:00
perf: fetch cached item group defaults, avoid query
This commit is contained in:
@@ -725,23 +725,9 @@ class Item(Document):
|
||||
if self.item_defaults or not self.item_group:
|
||||
return
|
||||
|
||||
item_defaults = frappe.db.get_values(
|
||||
"Item Default",
|
||||
{"parent": self.item_group},
|
||||
[
|
||||
"company",
|
||||
"default_warehouse",
|
||||
"default_price_list",
|
||||
"buying_cost_center",
|
||||
"default_supplier",
|
||||
"expense_account",
|
||||
"selling_cost_center",
|
||||
"income_account",
|
||||
],
|
||||
as_dict=1,
|
||||
)
|
||||
if item_defaults:
|
||||
for item in item_defaults:
|
||||
item_group = frappe.get_cached_doc("Item Group", self.item_group)
|
||||
if item_group.item_group_defaults:
|
||||
for item in item_group.item_group_defaults:
|
||||
self.append(
|
||||
"item_defaults",
|
||||
{
|
||||
@@ -762,9 +748,8 @@ class Item(Document):
|
||||
if (
|
||||
defaults.get("default_warehouse")
|
||||
and defaults.company
|
||||
and frappe.db.exists(
|
||||
"Warehouse", {"name": defaults.default_warehouse, "company": defaults.company}
|
||||
)
|
||||
and defaults.company
|
||||
== frappe.get_cached_value("Warehouse", defaults.default_warehouse, "company")
|
||||
):
|
||||
self.append(
|
||||
"item_defaults",
|
||||
|
||||
Reference in New Issue
Block a user