Beispiel #1
0
def get_next_possible_transitions(workflow_name, state, doc=None):
	transitions = frappe.get_all('Workflow Transition',
		fields=['allowed', 'action', 'state', 'allow_self_approval', 'next_state', '`condition`'],
		filters=[['parent', '=', workflow_name],
		['state', '=', state]])

	transitions_to_return = []

	for transition in transitions:
		is_next_state_optional = get_state_optional_field_value(workflow_name, transition.next_state)
		# skip transition if next state of the transition is optional
		if is_next_state_optional:
			continue
		if not is_transition_condition_satisfied(transition, doc):
			continue
		transitions_to_return.append(transition)

	return transitions_to_return
Beispiel #2
0
    def validate_workflow_conditions(doc):
        workflow = get_workflow_name(doc.doctype)
        if not workflow:
            return

        workflow_doc = frappe.get_doc("Workflow", workflow)
        current_state = doc.get(workflow_doc.workflow_state_field)
        roles = frappe.get_roles()

        transitions = []
        for transition in workflow_doc.transitions:
            if transition.next_state == current_state and transition.allowed in roles:
                if not is_transition_condition_satisfied(transition, doc):
                    continue
                transitions.append(transition.as_dict())

        if not transitions:
            frappe.throw(
                _("You are not allowed to update as per the conditions set in {} Workflow."
                  ).format(get_link_to_form("Workflow", workflow)),
                title=_("Insufficient Permissions"),
            )
Beispiel #3
0
def get_next_possible_transitions(workflow_name, state, doc=None):
    transitions = frappe.get_all(
        "Workflow Transition",
        fields=[
            "allowed", "action", "state", "allow_self_approval", "next_state",
            "`condition`"
        ],
        filters=[["parent", "=", workflow_name], ["state", "=", state]],
    )

    transitions_to_return = []

    for transition in transitions:
        is_next_state_optional = get_state_optional_field_value(
            workflow_name, transition.next_state)
        # skip transition if next state of the transition is optional
        if is_next_state_optional:
            continue
        if not is_transition_condition_satisfied(transition, doc):
            continue
        transitions_to_return.append(transition)

    return transitions_to_return