<commit_before>import frappe

# `skip_for_doctype` was a un-normalized way of storing for which
# doctypes the user permission was applicable.
# in this patch, we normalize this into `applicable_for` where
# a new record will be created for each doctype where the user permission
# is applicable
#
# if the user permission is applicable for all doctypes, then only
# one record is created

def execute():
	frappe.reload_doctype('User Permission')
	for user_permission in frappe.get_all('User Permission', fields=['*']):
		skip_for_doctype = user_permission.skip_for_doctype.split('\n')
		if skip_for_doctype:
			# only specific doctypes are selected
			# split this into multiple records and delete
			frappe.db.sql('delete from `tabUser Permission` where name=%s', user_permission.name)
			user_permission.name = None
			user_permission.skip_for_doctype = None
			for doctype in skip_for_doctype:
				if doctype:
					new_user_permission = frappe.new_doc('User Permission')
					new_user_permission.update(user_permission)
					print(test)
					new_user_permission.applicable_for = doctype
					new_user_permission.db_insert()<commit_msg>Add a patch to remove skip_for_doctype<commit_after>import frappe

# `skip_for_doctype` was a un-normalized way of storing for which
# doctypes the user permission was applicable.
# in this patch, we normalize this into `applicable_for` where
# a new record will be created for each doctype where the user permission
# is applicable
#
# if the user permission is applicable for all doctypes, then only
# one record is created

def execute():
	# frappe.db.sql('delete from `tabUser Permission`')
	# frappe.get_doc({'doctype': 'User Permission', u'_liked_by': None, u'modified_by': u'Administrator', u'name': u'76783e783a', u'parent': None, u'_assign': None, u'_user_tags': None, u'for_value': u'User', u'idx': 0, u'parenttype': None, u'allow': u'DocType', u'user': u'<EMAIL>', u'skip_for_doctype': u'', u'applicable_for': None, u'owner': u'Administrator', u'docstatus': 0, u'_comments': None, u'parentfield': None}).insert()
	# frappe.get_doc({'doctype': 'User Permission', u'_liked_by': None, u'modified_by': u'Administrator', u'name': u'456f1be7c5', u'parent': None, u'_assign': None, u'_user_tags': None, u'for_value': u'DocType', u'idx': 0, u'parenttype': None, u'allow': u'DocType', u'user': u'<EMAIL>', u'skip_for_doctype': u'Activity Log\nAddress\nAuto Repeat\nBulk Update\nCalendar View\nContact\nCustom Field\nCustom Script\nData Migration Mapping\nDesktop Icon\nDocType\nEmail Account\nEmail Domain\nEvent\nFeedback Trigger\nGSuite Templates\nIntegration Request\nList Filter\nNotification\nPayment Gateway\nPrint Format\nProperty Setter\nReport\nSuccess Action\nTag Category\nUser Permission\nVersion\nView log\nWebhook\nWorkflow\nWorkflow Action', u'applicable_for': None, u'owner': u'Administrator', u'docstatus': 0, u'_comments': None, u'parentfield': None}).insert()
	# frappe.get_doc({'doctype': 'User Permission', u'_liked_by': None, u'modified_by': u'Administrator', u'name': u'87e85fb24f', u'parent': None, u'_assign': None, u'_user_tags': None, u'for_value': u'Review', u'idx': 0, u'parenttype': None, u'allow': u'Workflow Action Master', u'user': u'<EMAIL>', u'skip_for_doctype': u'Workflow Action Master', u'applicable_for': None, u'owner': u'Administrator', u'docstatus': 0, u'_comments': None, u'parentfield': None}).insert()
	frappe.reload_doctype('User Permission')
	for user_permission in frappe.get_all('User Permission', fields=['*']):
		if not user_permission.skip_for_doctype: continue
		skip_for_doctype = user_permission.skip_for_doctype.split('\n')
		if skip_for_doctype:
			# only specific doctypes are selected
			# split this into multiple records and delete
			frappe.db.sql('delete from `tabUser Permission` where name=%s', user_permission.name)
			user_permission.name = None
			user_permission.skip_for_doctype = None
			for doctype in skip_for_doctype:
				if doctype:
					new_user_permission = frappe.new_doc('User Permission')
					new_user_permission.update(user_permission)
					new_user_permission.applicable_for = doctype
					new_user_permission.db_insert()
{'fraction_non_alphanumeric': 0.12135102533172497, 'fraction_numerical': 0.006272617611580217, 'mean_word_length': 6.160621761658031, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '2132860', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1346, 'n_words': 363}