Odoo Help


Understanding recordsets in the new api

on 8/17/16, 9:55 AM 517 views

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.

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

on 8/18/16, 2:32 AM
Giezel Esteves
On 8/23/16, 4:13 AM
def do_something(self):
    print 'self', self.id
    for r in self:
        print 'r', r.id

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/17/16, 9:55 AM
Seen: 517 times
Last updated: 8/23/16, 4:13 AM