Odoo Help

Welcome!

This community 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.

0

Understanding recordsets in the new api

By
Prowler
on 8/17/16, 9:55 AM 140 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..

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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