[fix] remove warehouse from Stock Settings if warehouse wont exists (#11487)

diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 486cd7c..220250b 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -456,3 +456,4 @@
 erpnext.patches.v9_0.set_uoms_in_variant_field
 erpnext.patches.v9_0.copy_old_fees_field_data
 erpnext.patches.v9_0.set_pos_profile_name
+erpnext.patches.v9_0.remove_non_existing_warehouse_from_stock_settings
\ No newline at end of file
diff --git a/erpnext/patches/v9_0/remove_non_existing_warehouse_from_stock_settings.py b/erpnext/patches/v9_0/remove_non_existing_warehouse_from_stock_settings.py
new file mode 100644
index 0000000..33dc519
--- /dev/null
+++ b/erpnext/patches/v9_0/remove_non_existing_warehouse_from_stock_settings.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+	default_warehouse = frappe.db.get_value("Stock Settings", None, "default_warehouse")
+	if default_warehouse:
+		if not frappe.db.get_value("Warehouse", {"name": default_warehouse}):
+			frappe.db.set_value("Stock Settings", None, "default_warehouse", "")
\ No newline at end of file