diff --git a/erpnext/setup/doctype/brand/brand.py b/erpnext/setup/doctype/brand/brand.py index cf3f4744391..ccb8b71e64f 100644 --- a/erpnext/setup/doctype/brand/brand.py +++ b/erpnext/setup/doctype/brand/brand.py @@ -35,7 +35,7 @@ def get_brand_defaults(item, company): for d in brand.brand_defaults or []: if d.company == company: - row = copy.deepcopy(d.as_dict()) + row = d.as_dict(no_private_properties=True) row.pop("name") return row diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 7170f600f7f..d064fab2fea 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -90,7 +90,7 @@ def get_item_group_defaults(item, company): for d in item_group.item_group_defaults or []: if d.company == company: - row = copy.deepcopy(d.as_dict()) + row = d.as_dict(no_private_properties=True) row.pop("name") return row diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 90b23733b1d..4b93ccae724 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -1277,7 +1277,7 @@ def get_item_defaults(item_code, company): for d in item.item_defaults: if d.company == company: - row = copy.deepcopy(d.as_dict()) + row = d.as_dict(no_private_properties=True) row.pop("name") out.update(row) return out diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index b3b37277791..2681d3c69ab 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -585,20 +585,15 @@ def get_item_warehouse_(ctx: ItemDetailsCtx, item, overwrite_warehouse, defaults or ctx.warehouse ) - if not warehouse: - defaults = frappe.defaults.get_defaults() or {} - warehouse_exists = frappe.db.exists( - "Warehouse", {"name": defaults.default_warehouse, "company": ctx.company} - ) - if defaults.get("default_warehouse") and warehouse_exists: - warehouse = defaults.default_warehouse - else: warehouse = ctx.warehouse if not warehouse: default_warehouse = frappe.get_single_value("Stock Settings", "default_warehouse") - if frappe.db.get_value("Warehouse", default_warehouse, "company") == ctx.company: + if ( + default_warehouse + and frappe.get_cached_value("Warehouse", default_warehouse, "company") == ctx.company + ): return default_warehouse return warehouse