'Clear descendant paths if role type has changed
@param form: the CRUD form'

@staticmethod
def pr_role_onvalidation(form):

    form_vars = form.vars
    if (not form_vars):
        return
    if ('role_type' in form_vars):
        role_id = form.record_id
        if (not role_id):
            return
        role_type = form_vars.role_type
        db = current.db
        rtable = db.pr_role
        role = db((rtable.id == role_id)).select(rtable.role_type, limitby=(0, 1)).first()
        if (role and (str(role.role_type) != str(role_type))):
            if (str(role_type) != str(OU)):
                form_vars['path'] = None
            current.s3db.pr_role_rebuild_path(role_id, clear=True)
    return
