Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
38102 มุมมอง

I'm creating a record through a RPC call and want to calculate some fields on the model using the option store=True,  my question is: 


If I use the store=True option the field it's computed everytime i open that record or just the first time? 


Can't find a clear explanation about that in the documentation, hope you can help my about this.

Regards



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Whether stored or not stored, computed fields have a compute method. The annotation on the compute method specifies when the re-calculation should run, depending on if it's stored or not.

For example (stored):

@api.depends('name', 'surname')
def compute_display_name(self):
# This will be called every time the name or surname field changes
pass

display_name = fields.Char(compute=compute_display_name, store=True)

For example (not stored):

def compute_display_name(self):
# This will be called every time the field is viewed
pass

display_name = fields.Char(compute=compute_display_name, store=False)
อวตาร
ละทิ้ง
ผู้เขียน

Thanks for your answer

you should make sure if the function will be invoked if the flag store=true with the decorator depends. Just check

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 23
2579
Computed field not updating in form view แก้ไขแล้ว
3
พ.ค. 23
17482
2
ก.ค. 22
7259
What does compute_sudo do? แก้ไขแล้ว
1
ก.ย. 21
14460
How to search by odoo computed field? แก้ไขแล้ว
3
ก.พ. 24
18357