This makes use of prefetching the .payment OneToOneFields' reverse relations to efficiently get the payable for payments.
As this does not introduce a duplicate relation in the database, it should be more robust.
In the long term, I do think moving to only a GenericForeignKey from Payment to payable would be better, that seems like a change that is very likely to break something. So I'd rather just get this working properly in a way that is certain not to break stuff.
Replacing the 1to1's with a reverse generic FK would still be nice to do some day, but I don't think we should have both as in #2126.
TODO:
[x] Add queryable property to allow filtering on no or multiple linked payables.
Supersedes #2126. Closes #1957. Closes #2034.
Summary
This makes use of prefetching the.payment OneToOneFields' reverse relations to efficiently get the payable for payments.
As this does not introduce a duplicate relation in the database, it should be more robust. In the long term, I do think moving to only a GenericForeignKey from Payment to payable would be better, that seems like a change that is very likely to break something. So I'd rather just get this working properly in a way that is certain not to break stuff.
Replacing the 1to1's with a reverse generic FK would still be nice to do some day, but I don't think we should have both as in #2126.
TODO:
How to test