Skip to Content
Menú
This question has been flagged
2 Respostes
3713 Vistes

Please look at the following code block:


    class hr_payslip:
...
        @api.multi      # same behavior with or without this line 
        def do_something(self):
            print "self------------------------------->",self
            for r in self:
                print "r------------------------------->",r


I'm overriding a hr.payslip model and I need to access an id field inside this method. The problem is that it doesn't make sense to me what gets printed:

self-------------------------------> hr.payslip(hr.payslip(1,),)

r-------------------------------> hr.payslip(hr.payslip(1,),)

Why is it the same thing inside and outside of for loop. If it's always a 'recordset', how would one access one record's field.



Avatar
Descartar
Autor

I posted this to StackOverflow, so no need to publish now..

Best Answer
@api.model        
def do_something(self):
    print 'self', self.id
    for r in self:
        print 'r', r.id
Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de febr. 25
2045
0
de gen. 25
1789
1
de des. 24
2242
1
de juny 22
6664
1
d’oct. 20
3349