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

Hello guys, I changing compute logic of a compute stored field but the field is not recomputed (the dependence not change, only the logic change). I need it stored. Is there away to achived it. Thank you guy so much.

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

This is all not accurate. 

In odoo17 the only thing you need to do is call the method and then commit.

for record in env['your.model'].search([]):
​record._your_compute_method()
​# you can also commit after each commit in case you have concurrency errors that are difficult to track down
env.cr.commit()


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

The following code works in v16:

model = env['your.model']
env.add_to_compute(model._fields['your_fields_to_recompute'], model.search([]))
model.recompute()

The following for v17:

model = env['your.model']
env.add_to_compute(model._fields['your_fields_to_recompute'], model.search([]))
model._recompute_recordset()


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

Hi,

If the dependencies are properly set for the stored computed field, the compute logic will get retrigerred whenever there is a change in the dependency.

After adding your new logic, if the re-computation is not properly working, make sure no dependencies are missed. If you are sure the dependencies are correctly given, then please update the question with the relevant codes.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
15312
Compute Fields Đã xử lý
2
thg 7 24
2370
1
thg 1 24
1783
1
thg 7 22
2197
4
thg 3 24
11075