'Check if a specific group has the access mode to the specified model'

@api.model
def check_group(self, model, mode, group_ids):

    assert (mode in ('read', 'write', 'create', 'unlink')), 'Invalid    access    mode'
    if isinstance(model, models.BaseModel):
        assert (model._name == 'ir.model'), 'Invalid    model    object'
        model_name = model.name
    else:
        model_name = model
    if isinstance(group_ids, (int, long)):
        group_ids = [group_ids]
    query = '    SELECT    1    FROM    ir_model_access    a\n                                                                                JOIN    ir_model    m    ON    (m.id    =    a.model_id)\n                                                                                WHERE    a.active    AND    a.perm_{mode}    AND\n                                                                                                m.model=%s    AND    (a.group_id    IN    %s    OR    a.group_id    IS    NULL)\n                                                                '.format(mode=mode)
    self._cr.execute(query, (model_name, tuple(group_ids)))
    return bool(self._cr.rowcount)
