Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
10085 Переглядів

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


Аватар
Відмінити
Найкраща відповідь

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)

Аватар
Відмінити
Найкраща відповідь

More on...Python List

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




Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
квіт. 25
3127
3
груд. 22
10869
5
квіт. 24
41128
6
квіт. 24
38075
2
лип. 19
765