Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
1758 Näkymät

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})      

Avatar
Hylkää

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()

Paras vastaus

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

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
maalisk. 25
1591
4
huhtik. 24
174497
0
jouluk. 23
2336
5
heinäk. 25
228928
1
jouluk. 22
3480