import xhiveframework


def execute():
	from xhiveerp.setup.setup_wizard.operations.install_fixtures import add_uom_data

	xhiveframework.reload_doc("setup", "doctype", "UOM Conversion Factor")
	xhiveframework.reload_doc("setup", "doctype", "UOM")
	xhiveframework.reload_doc("stock", "doctype", "UOM Category")

	if not xhiveframework.db.a_row_exists("UOM Conversion Factor"):
		add_uom_data()
	else:
		# delete conversion data and insert again
		xhiveframework.db.sql("delete from `tabUOM Conversion Factor`")
		try:
			xhiveframework.delete_doc("UOM", "Hundredweight")
			xhiveframework.delete_doc("UOM", "Pound Cubic Yard")
		except xhiveframework.LinkExistsError:
			pass

		add_uom_data()
