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

What's the diference between:

This:

def aprovar(self): 

 self.status = 'aprovado'

And this:

def aprovar(self): 

for record in self
    record.write({'field': value})      

Аватар
Відмінити

The self is iterated over the for loop is to solve the issue with single ton error, there is possibility for receiving multiple records at a time in self, so if you haven't iterated self over a for loop, you will get a error. Suppose if we call this button from action button of tree view, self can hold multiple values.

To solve the singleton error, either you have to iterate over the for loop or use self.ensure_one()

Найкраща відповідь

it for multiple record, you will get expected singleton error if you have multiple record and not use for rec in self: 

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
бер. 25
1592
4
квіт. 24
174505
0
груд. 23
2338
5
лип. 25
228950
1
груд. 22
3481