The error message “RecursionError: maximum recursion depth exceeded while calling a Python object” is a safety mechanism in Python. It prevents your program from entering an infinite loop and using up all the stack space. This error usually occurs when the base case of a recursive function is not defined correctly.
In your case, the error might be due to the way you’re calling the super function in your __init__ method. When you call super(ResUsers, self).__init__(pool, cr), it calls the __init__ method of the parent class, which is res.users. If res.users is also inheriting from ResUsers, it will call the __init__ method of ResUsers again, leading to an infinite loop.
Here’s how you can fix this:
class ResUsers(models.Model):
_inherit = 'res.users'
def __init__(self, pool, cr):
super(models.Model, self).__init__(pool, cr) # Call the __init__ method of models.Model instead of res.users
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
type(self).SELF_WRITEABLE_FIELDS.extend(['token', 'checkin'])
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
type(self).SELF_READABLE_FIELDS.extend(['token', 'checkin'])
token = fields.Char("Device Token", default="[]", groups="base.group_user")
checkin = fields.Boolean(string='Check-in', default=False, groups="base.group_user")
@api.model
def create(self, vals):
user = super(ResUsers, self).sudo().create(vals)
_logger.info("user %s", user)
return user
This code calls the __init__ method of models.Model instead of res.users, which should prevent the infinite loop.