John
John

Reputation: 131

Issues Creating User in OpenERP

I am trying to create user in openerp by python coding. I need to create a user for my website on odoo whenever a new user wants to signup. How can I achieve that? I am doing the following:

def register_user(self, **post):
    cr, uid, context = request.cr, request.uid, request.context
    user_obj = request.registry.get('res.users')    
    user_info = {}
    user_info["name"] = post.get("name")
    user_info["email"] = post.get("email")
    user_info["password"] = post.get("password")

    user_created = user_obj.create(cr, uid, vals_user, context)

    return request.website.render("custom_module.custom_template")

However, I am getting an error here: 'You cannot create a new user from here. To create new user please go to configuration panel'

Can anyone suggest where I might be going wrong? Thanks for your help in advance.

Upvotes: 1

Views: 2796

Answers (2)

Nauman Sharif
Nauman Sharif

Reputation: 183

self.env['res.users'].create({ "name": 'Name', "email": 'Email', "login": 'Email' })

Upvotes: 0

gabrieloliveira
gabrieloliveira

Reputation: 570

The error refers to this code in server/addons/mail/res_users.py:

def create(self, cr, uid, data, context=None):
    # create default alias same as the login
    if not data.get('login', False):
        raise osv.except_osv(_('Invalid Action!'), _('You may not create a user. To create new users, you should use the "Settings > Users" menu.'))

So, this happens because you don't set login in param data. login is the username field of res.users

Upvotes: 3

Related Questions