Reference field stored in transaction cache after being deleted
The Reference
field instances are stored in the transaction cache like the Many2One
but for Reference
field we do not manage "ON DELETE", instead we check the reference id in the method Reference.get
.
So when the target of a reference field is deleted, it may still be stored in the transaction cache and so it is used without checking if the record still exist.
This behavior breaks the modularity of the code because working code can crash because some extension delete the target of a reference field.
I think the simpler solution is to not store in the transaction cache the Reference
field instances like we do for xxx2Many
fields. So they will be stored in the local cache which is cleared as soon as ModelStorage.delete
is called.