跳至内容
菜单
此问题已终结
2 回复
907 查看

when searching in Odoo doc ,I found that: 

Imagine 2 models A and B

if B has a related field from A like A.age ,why does odoo store in the B.age the link to A.age not the actual value . the link costs more memory than the actual value 

形象
丢弃
最佳答案

Hi,


* A related field in Odoo does not store a “link” in memory in the same sense as a pointer or reference object.


* The related field behaves like a computed field that pulls its value on demand from the source model (A.age in your example).


* Unless you set store=True, Odoo does not persist the value in the database table of model B, it computes it every time it's accessed.


* The data type remains the same as the source field (bool, int, etc.), not a reference or pointer type.


* When you use store=True,

      - Odoo creates a column in model_b's table to store the value.

      - It’s synced automatically using compute triggers (depends).

      - Now it does use memory/storage, but stores the value directly as int, not a reference.



Hope it helps



形象
丢弃
最佳答案

It's related so there must be a link somewhere in case the record get updated. Depending on the type of data, the link would not necessarily be more memory expensive compared to the value: such as an image, a big html content. My wife used to write her meeting schedule on a postit and put it on the fridge as reminder and she doesn't want to listening to my lecturing on single version of truth only to find out sometimes the meetings are rescheduled and she misses them. In ERP systems like Odoo, data consitency is of crucial values compared to be economical saving a few kb here and there.

形象
丢弃
编写者

Thanks for clarification ,but the question if I have a bool or Int value ,Is storing links more memory expensive and that means that the data type of related fields is something else rather than the actual value type ?

相关帖文 回复 查看 活动
5
5月 24
13802
1
2月 24
2251
7
7月 16
6134
0
6月 24
1448
3
2月 21
16720