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

Hello

This is my Pb :

I have inherited the model hr.employee and I want to overload browse method to display only certain employees.

So I did this :

 class hr_employee(models.Model):
_name = 'hr.employee'
_inherit = 'hr.employee'
#...
@api.multi
def browse(self, arg):
return super(hr_employee, self).browse([5,6,7])

 

But as you can imagine, I have not the desired result.

Here is the log :

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 362, in old_api
recs = self.browse(cr, uid, ids, context)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 362, in old_api
recs = self.browse(cr, uid, ids, context)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
RuntimeError: maximum recursion depth exceeded

 

Can you help me please ?


頭像
捨棄
作者 最佳答案

Hi Axel,

I tried your solution, but I have the same error. 


頭像
捨棄

hi, try : return self.env['res.employee'].browse(5, 6, 7)

作者

Hi Guillaume, I tried this but had the same error.

最佳答案

@Khatir Metahri
You need to call directly the browse method of models.Model, like:

class hr_employee(models.Model):

_name = 'hr.employee'

_inherit = 'hr.employee'

#...

@api.multi

def browse(self, arg):

return models.Model.browse(self,[5,6,7])

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
4
3月 20
38875
2
3月 15
7930
3
7月 25
8682
1
5月 25
1005
0
1月 24
1692