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

I have a field and a function for computing this field

'score' : fields. ....
'myfield' : fields.function(_calculate_field,...)
the function like that: (I compute 'myfield' by 'score')
def _calculate_field(self, cr, uid, ids, arg, context=None):
    result = {} for i in range(len(ids)):     item = self.browse(cr, uid, ids[i], context=context)        if item.data:
            ...
            result[ids[i]] = ... else:     result[ids[i]] = '' return result

It work both tree view and form view, it is to heavy because it compute all the records.
I want it just work when I click on 1 record and access to form field, and compute just this record

Sorry for my bad english, thanks for any help

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

Hai Tai,

A easy way to achieve this is that just remove the compute field from the tree view and give it in the form view.

If you want to see this fields in the tree view, then just add a test field in the form view and give compute function for that field and write values to other field ( myfield)  from that compute function, after all you can keep this test field invisible in the form.


Thanks

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

ohh, it is a easy way. Tks for help :D

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 19
3987
1
thg 3 15
8358
1
thg 7 25
363
0
thg 7 25
400
1
thg 5 25
891