def merge_records(env, model_name, record_ids, target_record_id,
                  field_spec=None, method='orm', delete=True,
                  exclude_columns=None):
    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.")
    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)
        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)
        if delete:
            _delete_records_sql(env, model_name, record_ids, target_record_id)