Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
3669 Tampilan

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
Buang
Penulis

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

Jawaban Terbai
@api.model        
def do_something(self):
    print 'self', self.id
    for r in self:
        print 'r', r.id
Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Feb 25
1981
0
Jan 25
1721
1
Des 24
2181
1
Jun 22
6595
1
Okt 20
3308