跳至內容
選單
此問題已被標幟
2 回覆
3684 瀏覽次數

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

最佳答案
@api.model        
def do_something(self):
    print 'self', self.id
    for r in self:
        print 'r', r.id
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
2月 25
1996
0
1月 25
1757
1
12月 24
2196
1
6月 22
6622
1
10月 20
3312