Fetching the data from warehouse tree and showing the data in customer form

#Problem Statement

Whenever a Customer is Created then automatically a warehouse should be created based on Customer Naming format( Eg Customer:- Loki , a warehouse is created automatically :- Loki- CF warehouse)

Once Customer warehouse is created in Warehouse Tree then on reload of customer form , it should show “customer warehouse name” in a custom field called customer warehouse . (i.e Loki Warehouse should appear in custom field of Customer Warehouse in Customer window )

To achieve this we need hooks.py and customer.py file

#code snippet in hooks
doc_events = {
“Customer”: {

	"before_insert": "furniture.furniture.doctype.customer.customer.set_customer_warehouse"
}

}

#code snippet in customer.py

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
#class Customer(Document):
def set_customer_warehouse(customer,method): #Customer doctype object
	#frappe.msgprint("New Customer")
	#frappe.msgprint("Customer Warehouse is Empty")
	settings=frappe.get_single('Rental Settings') #declaring a variable settings
	cust_warehouse=frappe.get_doc({			
		"doctype": "Warehouse",
		"warehouse_name": customer.customer_name,
		"parent_warehouse" : settings.get("base_customer_warehouse"),
		"company": "CityFurnish"
	})
	cust_warehouse.insert()

	frappe.msgprint(cust_warehouse.warehouse_name)
	cust_warehouse.reload()
	frappe.msgprint("Created Customer Warehouse")
	customer.customer_warehouse = settings.get("base_customer_warehouse")

Note Rental Settings is a single doctype & its linked with Warehouse.

Issues:-
Customer Warehouse is created in Warehouse Tree but on reload of Customer Form , the customer warehouse name is not appearing.

Please find the ScreenShots

i didn’t get anywhere you set your warehouse field with new warehouse. you should set your warehouse field

try this.

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
#class Customer(Document):
def set_customer_warehouse(customer,method): #Customer doctype object
	#frappe.msgprint("New Customer")
	#frappe.msgprint("Customer Warehouse is Empty")
	settings=frappe.get_single('Rental Settings') #declaring a variable settings
	cust_warehouse=frappe.get_doc({			
		"doctype": "Warehouse",
		"warehouse_name": customer.customer_name,
		"parent_warehouse" : settings.get("base_customer_warehouse"),
		"company": "CityFurnish"
	}).insert()
	frappe.msgprint(cust_warehouse.warehouse_name)
	frappe.msgprint("Created Customer Warehouse")
	customer.customer_warehouse = cust_warehouse.name or settings.get("base_customer_warehouse")

Thanks its working