import xhiveframework


def execute():
	if "agriculture" in xhiveframework.get_installed_apps():
		return

	xhiveframework.delete_doc("Module Def", "Agriculture", ignore_missing=True, force=True)

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

	reports = xhiveframework.get_all("Report", {"module": "agriculture", "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": "agriculture", "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": "agriculture", "custom": 0}, pluck="name")
	for doctype in doctypes:
		xhiveframework.delete_doc("DocType", doctype, ignore_missing=True)

	xhiveframework.delete_doc("Module Def", "Agriculture", ignore_missing=True, force=True)
