Skip to Content
Menu
This question has been flagged
1 Reply
3880 Views

Hello All,

i am trying to remove many2many fields data in write methon when some code write, but it's not working it wil give me error: RecursionError: maximum recursion depth exceeded while calling a Python object

i have tried: [(6, 0, IDS)] and [(5, 0, 0)]

can anyone suggest me how to clear myny2many field in write method when some field value change

Avatar
Discard
Best Answer

Hi,

You might be calling the write method recursive from the write method, so you are getting the maximum recursion exceeded message. If you are updating the many2many field using write method or using . operator, just try to update the vals.


See sample code below for removing the data from many2many field named tags in res.partner model.

class Partner(models.Model):
_inherit = 'res.partner'

@api.multi
def write(self, vals):
vals['category_id'] = [(5, 0, 0)]
res = super(Partner, self).write(vals)
return res

Thanks

Avatar
Discard
Related Posts Replies Views Activity
2
Jan 19
12227
1
Dec 19
4669
1
Feb 24
839
1
Apr 24
924
0
Jul 24
1507