# Copyright (c) 2015, Xhive Global Ltd. and Contributors
# License: MIT. See LICENSE
import xhiveframework


def add_custom_field(doctype, fieldname, fieldtype="Data", options=None):
	xhiveframework.get_doc(
		{
			"doctype": "Custom Field",
			"dt": doctype,
			"fieldname": fieldname,
			"fieldtype": fieldtype,
			"options": options,
		}
	).insert()


def clear_custom_fields(doctype):
	xhiveframework.db.delete("Custom Field", {"dt": doctype})
	xhiveframework.clear_cache(doctype=doctype)
