I've integrated several remote webservices into our Odoo EE v9.
My goal is:
to call the webservice on create (so after the ORM grants authorization).
call the remote service only once, not more.
if this call succeeded before? return existing record.
[optionally] work on a separate transaction to avoid unnecessary rollbacks.
I've created two flavors:
create -> call webservice
create -> do nothing until -> read computed field (stored/rw) -> call webservice
Both methods end up in an uncontrollable entanglement of computations and recomputations. This happend majorly inside the cache layer and I can't unravel what's happening when. Sometimes it calls 3 times, sometimes more. Sometimes I open a parent and recomputations happen eventhough store=True. I've also tried with env.norecompute.
Is there anyone who holds some kind of lifecycle documentation on the cache? Does cache gets written by convert_to_cache on a field (and on a record)? What happens when cache gets invalidated? How can I use a computed stored field that calculates exactly once? These are all questions I can't find an answer to, even though I have put a lot of effort in them.
Regards,
Rik
p.s. Some interesting "closer to the cache" tech docs from Raphael Collet:
https://www.odoo.com/nl_NL/slides/slide/advanced-features-of-the-api-206
https://www.odoo.com/nl_NL/slides/slide/how-to-optimize-the-performance-229/pdf_content