# Copyright (c) 2022, SolutionERP LLC and contributors
# For license information, please see license.txt

import xhiveframework


def execute():
	for doctype in ["Purchase Order", "Purchase Receipt", "Purchase Invoice", "Supplier Quotation"]:
		xhiveframework.db.sql(
			"""
				UPDATE `tab{doctype}`
				SET is_subcontracted = 0
				where is_subcontracted in ('', 'No') or is_subcontracted is null""".format(
				doctype=doctype
			)
		)
		xhiveframework.db.sql(
			"""
				UPDATE `tab{doctype}`
				SET is_subcontracted = 1
				where is_subcontracted = 'Yes'""".format(
				doctype=doctype
			)
		)

		xhiveframework.reload_doc(xhiveframework.get_meta(doctype).module, "doctype", xhiveframework.scrub(doctype))
