Thanks. Just found out that the credit memos in my case are being created automatically by scheduled scripts triggered when a payment is accepted for an invoice.
So, I'm still trying to find how to "inherit" the project from the invoice to the credit memo.