<commit_before>import frappe

def execute():
	# for price list
	countries = frappe.db.sql_list("select name from tabCountry")

	for doctype in ("Price List", "Shipping Rule"):
		frappe.reload_doctype(doctype)

		for at in frappe.db.sql("""select name, parent, territory from `tabApplicable Territory` where
			parenttype = %s """, doctype, as_dict=True):
			if at.territory in countries:
				parent = frappe.get_doc(doctype, at.parent)
				if not parent.countries:
					parent.append("countries", {"country": at.territory})
				parent.save()


	frappe.delete_doc("DocType", "Applicable Territory")<commit_msg>[fix] [patch] convert_applicable_territory<commit_after>import frappe

def execute():
	frappe.reload_doctype("Price List Country")
	frappe.reload_doctype("Price List")
	frappe.reload_doctype("Shipping Rule")

	# for price list
	countries = frappe.db.sql_list("select name from tabCountry")

	for doctype in ("Price List", "Shipping Rule"):
		for at in frappe.db.sql("""select name, parent, territory from `tabApplicable Territory` where
			parenttype = %s """, doctype, as_dict=True):
			if at.territory in countries:
				parent = frappe.get_doc(doctype, at.parent)
				if not parent.countries:
					parent.append("countries", {"country": at.territory})
				parent.save()


	frappe.delete_doc("DocType", "Applicable Territory")
{'fraction_non_alphanumeric': 0.12874251497005987, 'fraction_numerical': 0.0, 'mean_word_length': 5.0225225225225225, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6340520', 'n_tokens_mistral': 495, 'n_tokens_neox': 437, 'n_words': 111}