Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4609 มุมมอง

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])

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to actually use and modify context? แก้ไขแล้ว
4
มี.ค. 20
38838
2
มี.ค. 15
7921
3
ก.ค. 25
8631
1
พ.ค. 25
927
0
ม.ค. 24
1665