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

Hello there,

I'm trying to understand a custom module for a customer.

What is this kind of "store" in this field declaration?

Usually, the store parameter takes the value False or True...

How do you name it? How to get info about this?

'to_invoice_hours': fields.function(_to_invoice_hours_get, string='Hours To Invoice',
        store = {
'project.task': (lambda self, cr, uid, ids, c={}: ids, ['timesheet_ids'], 10),
'account.analytic.line': (_get_task, ['task_id', 'unit_amount'], 10), }
)


Thanks for your comments.

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

If the store parameter is simply set to True, the stored values will never be recalculated, which in many cases is a bad thing and leads to wrong data later on. However, the store parameter in your example defines the conditions that would trigger the recalculation of the stored field's values. 

There is a good explanation of the recalculation triggers of the old API in this blog post. However, if you have the option to use the new API instead, writing the recalculation triggers becomes much, much simpler, as you can just use the @api.depends decorator.

Ảnh đại diện
Huỷ bỏ
Tác giả

Big thanks. Your words are perfect!

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
4320
0
thg 2 25
1315
0
thg 1 25
1138
1
thg 12 24
1463
1
thg 6 22
5601