From 5a61ea64961c860cda80c77f7439dea737e6d6cf Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 11 Aug 2026 18:58:49 +0530 Subject: [PATCH] test(stock): isolate warehouse account fixtures from class-level state FrappeTestCase on this branch rolls back per class, not per test, so sibling tests leak state. test_new_warehouse_can_inherit_inventory_account left an explicit account on the root group, which made later ambiguous fixtures resolve through the root: the insert validation stopped raising and the unresolved warehouse stayed in the map. The fixture helper now clears group warehouse accounts so every call re-establishes ambiguity. The fallback test also clears the account of the warehouse it picks, since a leftover explicit account skips the single-account fallback it asserts. --- erpnext/stock/doctype/warehouse/test_warehouse.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py index 051fb14e49d..4417e89a882 100644 --- a/erpnext/stock/doctype/warehouse/test_warehouse.py +++ b/erpnext/stock/doctype/warehouse/test_warehouse.py @@ -112,6 +112,7 @@ class TestWarehouse(FrappeTestCase): frappe.delete_doc("Account", "Extra Inventory Account - _TCIF") warehouse = frappe.get_doc("Warehouse", {"company": company, "is_group": 0}) + warehouse.db_set("account", None) single_account = frappe.db.get_value( "Account", {"account_type": "Stock", "is_group": 0, "company": company}, "name" ) @@ -250,6 +251,11 @@ def create_ambiguous_inventory_account_warehouse(): for warehouse_name in warehouses: frappe.db.set_value("Warehouse", warehouse_name, "account", single_account) + for group_warehouse in frappe.get_all( + "Warehouse", filters={"company": company, "is_group": 1}, pluck="name" + ): + frappe.db.set_value("Warehouse", group_warehouse, "account", None) + warehouse = frappe.get_doc("Warehouse", warehouses[0]) warehouse.db_set({"account": None, "disabled": 0})