def get_fk_to_update(connection, tables):
    """ Method to get back all columns referencing another table
    """
    fk2update = {}
    with connection.cursor() as c:
        for table in tables:
            if table not in fk2update:
                if table == 'ir.actions':
                    table = 'ir.actions.actions'
                query = (
                    """
SELECT tc.table_name, kcu.column_name
FROM information_schema.table_constraints AS tc JOIN
information_schema.key_column_usage AS kcu ON
tc.constraint_name = kcu.constraint_name JOIN
information_schema.constraint_column_usage AS
ccu ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY' AND
ccu.table_name='%s';"""
                     % table)
                c.execute(query)
                results = c.fetchall()
                fk2update[table] = results
    result = {}
    for pointed_table, fknames in fk2update.iteritems():
        for fkname in fknames:
            result['.'.join(fkname)] = pointed_table
    return result
