'Update the realm entity of the organisation after changing the
organisation type (otherwise type-dependent realm rules won\'t
ever take effect since the org_organisation record is written
before the org_organisation_organisation_type)
@param form: the Form'

@staticmethod
def org_organisation_organisation_type_onaccept(form):

    try:
        record_id = form.vars.id
    except AttributeError:
        return
    table = current.s3db.org_organisation_organisation_type
    row = current.db((table.id == record_id)).select(table.organisation_id, limitby=(0, 1)).first()
    if row:
        current.auth.set_realm_entity('org_organisation', row.organisation_id, force_update=True)
