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

hi ,

i want to compute length of list by function and store  result  in the empty field  , i have done this but it isnt working

count_line = fields.Integer('Result')

    @api.multi
    def on_change_lines_ids(self,line_ids):
        if line_ids :
                for line in line_ids :
                    x = len(line_ids)
                    self.count_line = x
                raise except_orm(_('Bien fait !'))

thanks to help me


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

Hi for this you can use decorators onchange or depends

I'll show an example of onchange. for this I believe line_ids is a many2many or one2many field with more than one record.and you want to store its length to a field

count_line = fields.Integer('Result')

@api.onchange('line_ids')
def onchange_line_ids(self):

     self.count_line = len(self.line_ids)

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

More on...Python List

http://net-informations.com/python/ds/lists.htm




Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 25
3665
3
thg 12 22
11579
5
thg 4 24
42138
6
thg 4 24
38992
2
thg 7 19
765