<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def merge_records(env, model_name, record_ids, target_record_id, field_spec=None, method='orm', delete=True, exclude_columns=None):
 """Merge several records into the target one. NOTE: This should be executed in end migration scripts for assuring that all the possible relations are loaded and changed. Tested on v10/v11. :param env: Environment variable :param model_name: Name of the model of the records to merge :param record_ids: List of IDS of records that are going to be merged. :param target_record_id: ID of the record where the rest records are going to be merge in. :param field_spec: Dictionary with field names as keys and forced operation to perform as values. If a field is not present here, default operation will be performed. See _adjust_merged_values_orm method doc for all the available operators. :param method: Specify how to perform operations. By default or specifying 'orm', operations will be performed with ORM, maybe slower, but safer, as related and computed fields will be recomputed on changes, and all constraints will be checked. :param delete: If set, the source ids will be unlinked. :exclude_columns: list of tuples (table, column) that will be ignored. """

    if exclude_columns is None:
        exclude_columns = []
    if field_spec is None:
        field_spec = {}
    if isinstance(record_ids, list):
        record_ids = tuple(record_ids)
    args0 = (env, model_name, record_ids, target_record_id)
    args = args0 + (exclude_columns, )
    args2 = args0 + (field_spec, )
    if target_record_id in record_ids:
        raise Exception("You can't put the target record in the list or "
                        "records to be merged.")
    # Check which records to be merged exist
    record_ids = env[model_name].browse(record_ids).exists().ids
    if not record_ids:
        return
    _change_generic(*args, method=method)
    if method == 'orm':
        _change_many2one_refs_orm(*args)
        _change_many2many_refs_orm(*args)
        _change_reference_refs_orm(*args)
        _change_translations_orm(*args)
        # TODO: serialized fields
        with env.norecompute():
            _adjust_merged_values_orm(*args2)
        env[model_name].recompute()
        if delete:
            _delete_records_orm(env, model_name, record_ids, target_record_id)
    else:
        _change_foreign_key_refs(*args)
        _change_reference_refs_sql(*args)
        _change_translations_sql(*args)
        # TODO: Adjust values of the merged records through SQL
        if delete:
            _delete_records_sql(env, model_name, record_ids, target_record_id)