跳至内容
菜单
此问题已终结
1 回复
1756 查看

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: 

形象
丢弃
相关帖文 回复 查看 活动
0
3月 25
1590
4
4月 24
174493
0
12月 23
2336
5
7月 25
228917
1
12月 22
3479