def check_values_selection_field(cr, table_name, field_name, allowed_values):
    """
        check if the field selection 'field_name' of the table 'table_name'
        has only the values 'allowed_values'.
        If not return False and log an error.
        If yes, return True.

    .. versionadded:: 8.0
    """
    res = True
    cr.execute("SELECT %s, count(*) FROM %s GROUP BY %s;" %
               (field_name, table_name, field_name))
    for row in cr.fetchall():
        if row[0] not in allowed_values:
            logger.error(
                "Invalid value '%s' in the table '%s' "
                "for the field '%s'. (%s rows).",
                row[0], table_name, field_name, row[1])
            res = False
    return res
def check_values_selection_field ( cr , table_name , field_name , allowed_values ) : res = True cr . execute ( "SELECT %s, count(*) FROM %s GROUP BY %s;" % ( field_name , table_name , field_name ) ) for row in cr . fetchall ( ) : if row [ 0 ] not in allowed_values : logger . error ( "Invalid value '%s' in the table '%s' " "for the field '%s'. (%s rows)." , row [ 0 ] , table_name , field_name , row [ 1 ] ) res = False return res
check if the field selection 'field_name' of the table 'table_name'
        has only the values 'allowed_values'.
        If not return False and log an error.
        If yes, return True.

    .. versionadded:: 8.0