mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 10:11:20 +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:
|
if self.item_defaults or not self.item_group:
|
||||||
return
|
return
|
||||||
|
|
||||||
item_defaults = frappe.db.get_values(
|
item_group = frappe.get_cached_doc("Item Group", self.item_group)
|
||||||
"Item Default",
|
if item_group.item_group_defaults:
|
||||||
{"parent": self.item_group},
|
for item in item_group.item_group_defaults:
|
||||||
[
|
|
||||||
"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:
|
|
||||||
self.append(
|
self.append(
|
||||||
"item_defaults",
|
"item_defaults",
|
||||||
{
|
{
|
||||||
@@ -762,9 +748,8 @@ class Item(Document):
|
|||||||
if (
|
if (
|
||||||
defaults.get("default_warehouse")
|
defaults.get("default_warehouse")
|
||||||
and defaults.company
|
and defaults.company
|
||||||
and frappe.db.exists(
|
and defaults.company
|
||||||
"Warehouse", {"name": defaults.default_warehouse, "company": defaults.company}
|
== frappe.get_cached_value("Warehouse", defaults.default_warehouse, "company")
|
||||||
)
|
|
||||||
):
|
):
|
||||||
self.append(
|
self.append(
|
||||||
"item_defaults",
|
"item_defaults",
|
||||||
|
|||||||
Reference in New Issue
Block a user