Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
8667 Lượt xem

Compute Field Value dose not get updated after adding Store = True even when the depends fields changed

?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Nevermind my previous answer (why can't I delete or edit it?)


Updates to dependencies do trigger the computed fields function to change the stored dependent field.  In my case there were added conditions within the computed field code that made it work for loading, but not for updating within the UI.  Removed those excess conditions, and everything worked.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello Loay elhaj,

Please find below example it may help you,

Please find code in Comment. 

I hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Ảnh đại diện
Huỷ bỏ

Example:

May be you have taken compute field without depends and you are trying to store data of field in database but due to store = True it will not update because old value store in database even though dependent field updated.

field_1 = field.Float('Field 1')
field_2 = field.Float('Field 2', compute='_compute_field', store=True)

@api.depends('field_1')
def _compute_field(self);
code....

You can refer below link for your reference:- https://www.odoo.com/documentation/15.0/developer/howtos/rdtraining/09_compute_onchange.html

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 3 25
9521
1
thg 2 21
3833
4
thg 10 20
9238
1
thg 7 25
2323
2
thg 7 25
7807