import influxframework


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

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

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

		add_uom_data()
