ebelair
ebelair

Reputation: 884

Disable invitation email when creating user

I don't know how to disable sending email invitation when i create or import user.

I tried to override auth_signup module with this code but i have a recursion error: Unknown error during import: : maximum recursion depth exceeded at row 2

And the code :

class res_users(models.Model):
    _inherit = 'res.users'

    @api.model
    def create(self, vals):
        user = super(res_users, self).with_context(no_reset_password=True).create(vals)

        return user

Upvotes: 0

Views: 1149

Answers (1)

Abu Uzayr
Abu Uzayr

Reputation: 154

with_context will cause a recursion error when applied with super. super calls the base class, which is not what you need. What you need is to update the context of the current instance of the class, which is self.

Therefore this should work:

class res_users(models.Model):
    _inherit = 'res.users'

    @api.model
    def create(self, vals):
        user = super(res_users, self.with_context(no_reset_password=True)).create(vals)

        return user

Upvotes: 1

Related Questions