diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index 1eaa8163bbe..8045bbdaadb 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -465,6 +465,7 @@ def get_items_from_product_bundle(row: str): parent item's active version. """ row, items = ItemDetailsCtx(json.loads(row)), [] + frappe.has_permission("Product Bundle", "read", row.get("product_bundle"), throw=True) if bundle_name := row.get("product_bundle"): bundle = frappe.db.get_value("Product Bundle", bundle_name, ["docstatus", "disabled"], as_dict=True) diff --git a/erpnext/stock/doctype/packed_item/test_packed_item.py b/erpnext/stock/doctype/packed_item/test_packed_item.py index 812596dd1e6..5a91978e9d9 100644 --- a/erpnext/stock/doctype/packed_item/test_packed_item.py +++ b/erpnext/stock/doctype/packed_item/test_packed_item.py @@ -232,6 +232,7 @@ class TestPackedItem(ERPNextTestSuite): # a disabled version is rejected frappe.db.set_value("Product Bundle", version, "disabled", 1) + self.addCleanup(frappe.db.set_value, "Product Bundle", version, "disabled", 0) self.assertRaises( frappe.ValidationError, get_items_from_product_bundle,