code: def _change_generic(env, model_name, record_ids, target_record_id,
                      exclude_columns, method='orm'):
      
      for model_to_replace, res_id_column, model_column in [
              ('calendar.event', 'res_id', 'res_model'),
              ('ir.attachment', 'res_id', 'res_model'),
              ('mail.activity', 'res_id', 'res_model'),
              ('mail.followers', 'res_id', 'res_model'),
              ('mail.message', 'res_id', 'model'),
              ('rating.rating', 'res_id', 'res_model'),
              ]:
          try:
              model = env[model_to_replace].with_context(active_test=False)
          except KeyError:
              continue
          if (model._table, res_id_column) in exclude_columns:
              continue
          if method == 'orm':
              records = model.search([
                  (model_column, '=', model_name),
                  (res_id_column, 'in', record_ids)])
              if records:
                  records.write({res_id_column: target_record_id})
                  logger.debug(
                      "Changed %s record(s) of model '%s'",
                      len(records), model_to_replace)
          else:
              logged_query(
                  env.cr,
                  """ UPDATE %(table)s
                      SET %(res_id_column)s = %(target_record_id)s
                      WHERE %(model_column)s = %(model_name)s
                      AND %(res_id_column)s in %(record_ids)s
                  """,
                  {
                      'table': AsIs(model._table),
                      'res_id_column': AsIs(res_id_column),
                      'model_column': AsIs(model_column),
                      'model_name': model_name,
                      'target_record_id': target_record_id,
                      'record_ids': record_ids,
                  }, skip_no_result=True)
docs: Update known generic style res_id/res_model references