import xhiveframework


def execute():
	modules = ["Hotels", "Restaurant"]

	for module in modules:
		xhiveframework.delete_doc("Module Def", module, ignore_missing=True, force=True)

		xhiveframework.delete_doc("Workspace", module, ignore_missing=True, force=True)

		reports = xhiveframework.get_all("Report", {"module": module, "is_standard": "Yes"}, pluck="name")
		for report in reports:
			xhiveframework.delete_doc("Report", report, ignore_missing=True, force=True)

		dashboards = xhiveframework.get_all("Dashboard", {"module": module, "is_standard": 1}, pluck="name")
		for dashboard in dashboards:
			xhiveframework.delete_doc("Dashboard", dashboard, ignore_missing=True, force=True)

		doctypes = xhiveframework.get_all("DocType", {"module": module, "custom": 0}, pluck="name")
		for doctype in doctypes:
			xhiveframework.delete_doc("DocType", doctype, ignore_missing=True)

	custom_fields = [
		{"dt": "Sales Invoice", "fieldname": "restaurant"},
		{"dt": "Sales Invoice", "fieldname": "restaurant_table"},
		{"dt": "Price List", "fieldname": "restaurant_menu"},
	]

	for field in custom_fields:
		custom_field = xhiveframework.db.get_value("Custom Field", field)
		xhiveframework.delete_doc("Custom Field", custom_field, ignore_missing=True)
