Workflow actions are being created for every user

Below code in is creating workflow action doctype for every user at every transition

Suppose I have 10,000 users registered on my frappe portal and I am creating a doctype using code (insert). So this code creates workflow action for all the 10,000 users which is time consuming. Hence I am facing performance issues.

Can anyone tell me why it is taking all the users for creating workflow action.

def filter_allowed_users(users, doc, transition):
	"""Filters list of users by checking if user has access to doc and
	if the user satisfies 'workflow transision self approval' condition
	from frappe.permissions import has_permission
	filtered_users = []
	for user in users:
		if (has_approval_access(user, doc, transition)
			and has_permission(doctype=doc, user=user)):
	return filtered_users

@revant_one have you came accross this scenario till now? I’ll be grateful to hear from you

if logic is too complex for workflow, use standard doctype controllers and doc_events and achieve it programmatically

1 Like