code: def date_to_datetime_tz(
          cr, table_name, user_field_name, date_field_name, datetime_field_name):
      
      cr.execute(
          """
          SELECT distinct(rp.tz)
          FROM %s my_table, res_users ru, res_partner rp
          WHERE rp.tz IS NOT NULL
              AND my_table.%s=ru.id
              AND ru.partner_id=rp.id
          """ % (table_name, user_field_name,))
      for timezone, in cr.fetchall():
          cr.execute("SET TIMEZONE=%s", (timezone,))
          values = {
              'table_name': table_name,
              'date_field_name': date_field_name,
              'datetime_field_name': datetime_field_name,
              'timezone': timezone,
          }
          logged_query(
              cr,
              """
              UPDATE %(table_name)s my_table
              SET %(datetime_field_name)s =
                  my_table.%(date_field_name)s::TIMESTAMP AT TIME ZONE 'UTC'
              FROM res_partner rp, res_users ru
              WHERE my_table.%(date_field_name)s IS NOT NULL
                  AND my_table.user_id=ru.id
                  AND ru.partner_id=rp.id
                  AND rp.tz='%(timezone)s';
              """ % values)
      cr.execute("RESET TIMEZONE")
docs: Take the related user's timezone into account when converting
      date field to datetime in a given table.
      This function must be call in post migration script.
  
      :param table_name : Name of the table where the field is;
      :param user_field_name : The name of the user field (res.users);
      :param date_field_name : The name of the old date field; \
      (Typically a legacy name, set in pre-migration script)
      :param datetime_field_name : The name of the new date field;
  
      .. versionadded:: 8.0