'Custom Modules Menu'

@classmethod
def menu_modules(cls):

    auth = current.auth
    has_role = auth.s3_has_role
    s3 = current.session.s3
    len_roles = len(s3.roles)
    if ((len_roles <= 2) or ((len_roles == 3) and has_role('RIT_MEMBER') and (not has_role('ADMIN')))):
        return [MM('Profile', c='hrm', f='person', args=[str(auth.s3_logged_in_person())], vars={'profile': 1})]
    system_roles = s3.system_roles
    ORG_ADMIN = system_roles.ORG_ADMIN
    s3db = current.s3db
    s3db.inv_recv_crud_strings()
    inv_recv_list = current.response.s3.crud_strings.inv_recv.title_list
    def hrm(item):
        return (has_role(ORG_ADMIN) or has_role('national_hr_manager') or has_role('hr_manager') or has_role('training_coordinator') or has_role('training_assistant') or has_role('surge_capacity_manager') or has_role('disaster_manager'))
    def inv(item):
        return (has_role('wh_manager') or has_role('national_wh_manager') or has_role(ORG_ADMIN))
    def basic_warehouse(i):
        if (not (has_role('national_wh_manager') or has_role(ORG_ADMIN))):
            return False
        else:
            return True
    def multi_warehouse(i):
        if (not (has_role('national_wh_manager') or has_role(ORG_ADMIN))):
            return False
        else:
            return True
    menu = [homepage('gis')(), homepage('hrm', 'org', name='Human    Talent', check=hrm)(MM('Human    Talent', c='hrm', f='human_resource', m='summary'), MM('National    Societies', c='org', f='organisation', vars=red_cross_filter), MM('Positions', c='hrm', f='job_title')), homepage('hrm', f='training_event', name='Training', check=hrm)(MM('Training    Centers', c='hrm', f='training_center'), MM('Training    Course    Catalog', c='hrm', f='course'), MM('Training    Events', c='hrm', f='training_event'), MM('External    Trainees', c='pr', f='person')), homepage('inv', 'supply', 'req', check=inv)(MM('Warehouses', c='inv', f='warehouse', m='summary', check=multi_warehouse), MM(inv_recv_list, c='inv', f='recv', check=multi_warehouse), MM('Sent    Shipments', c='inv', f='send', check=multi_warehouse), MM('Items', c='supply', f='item', check=basic_warehouse), MM('Catalogs', c='supply', f='catalog', check=basic_warehouse), M('Suppliers', c='inv', f='supplier', check=basic_warehouse)(), M('Facilities', c='inv', f='facility', check=basic_warehouse)(), M('Requests', c='req', f='req')()), homepage('project', f='project', m='summary')(MM('Projects', c='project', f='project', m='summary'))]
    if (has_role('surge_capacity_manager') or has_role('disaster_manager')):
        menu.append(homepage('deploy', name='RIT', f='mission', m='summary', vars={'~.status__belongs': '2'})(MM('Missions', c='deploy', f='mission', m='summary'), MM('Members', c='deploy', f='human_resource', m='summary')))
    return menu
