Message 76617

Author
ced
Date
2022-05-13.00:01:09
Message id
76617

Content

A common pattern is to access a Many2One with a context (ex: account on account.move.line with the company set in the context).
The ModelStorage.__getattr__ is not efficient because if the Many2One is already in the _cache then it skip eager load. But indeed it will need to also read the fields in the context which may not be in the _cache (ex: the company of account.move.line which is a Function field). In this case we re-read one by one the field and the context fields if at least one is not in _cache (ex: company of account.move.line).

For me we should skip eager loading only if the accessed field has no context (and neither the datetime field).
Also we should filter out only sibling ids if all the read fields are not in any of the transaction and local cache.
This way we make an extra read but for all the siblings at once instead of one by one and we instantiate all the Many2One at once and store them in the local cache.

History
Date User Action Args
2022-05-13 00:01:09cedsetmessageid: <1652392869.3356092.S2QHKXND53YDR3Z6.issue11481@tryton.org>
2022-05-13 00:01:09cedlinkissue11481 messages
2022-05-13 00:01:09cedcreate