콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
4513 화면

I've integrated several remote webservices into our Odoo EE v9.

My goal is:

  1. to call the webservice on create (so after the ORM grants authorization).

  2. call the remote service only once, not more.

  3. if this call succeeded before? return existing record.

  4. [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

아바타
취소
베스트 답변

Dear Rik,

The scenario you describe is confusing to me...

  • What does the data model on which you call create() represent?

  • You mention a computed field that gets recomputed.  What is that field?  What value does it store?  What is the link between that field and the webservice?

  • What kind of remote webservice do you use?  You wrote is should be called only once.  But is it once for all, once per server instance, once per request?

The "cache" you mention is the record cache.  It is a caching layer between the database and the record objects.

  • It is essentially a mapping from a pair (record, field) to a value.

  • The cache is written explicitly by field assignments like record.name = "foo", or implicitly by a prefetching mechanism that reads data from the database when you access a field like record.name.

  • A cache entry (record, field) is invalidated automatically when that field is modified in the database, or when dependencies of the field have been modified (this forces its recomputation).

  • It is used both for performance (minimize the number of queries to read data from the database), and to memoize the result of computed fields.

  • The cache is attached to a transaction (JSON/RPC request), and is dropped at the end of the transaction.  It is therefore not shared across transactions.

Regards,

Raphael

아바타
취소
관련 게시물 답글 화면 활동
0
7월 23
2361
Query caching 해결 완료
1
6월 25
11157
2
10월 21
3594
0
9월 19
98
1
7월 17
4237