Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

create openerp user through python code

By
supreeth
on 2/16/16, 6:30 AM 414 views

Hi guys,

How to Create openerp user through Python code ?

I have created a custom menu, there i need to create openerp user.

How can we override create method for this.

i refered below link:

\https://www.odoo.com/forum/help-1/question/how-to-create-openerp-user-through-python-code-34090

def create(self, cr, uid, vals, context=None):
user_obj = self.pool.get('res.users')
vals_user = {
'name': vals.get('name'),
'login': default_login,
#other required field
}
user_obj.create(cr, uid, vals_user, context)
result = super(hr_employee, self).create(cr, uid, vals, context=context)
return result

I didnt understood "'login': default_login",

How to do this? Is there any other method's?


Thanks,

1

Odoo

--Odoo --
1328
| 5 2 5
kerala, India
--Odoo --

Working as a Odoo Functional and Technical Expert

Odoo
On 2/16/16, 7:30 AM
Add these variable to create user in res.users

'login': fields.char('Login', size=64, required=True,
help="Used to log into the system"),
'password': fields.char('Password', size=64, invisible=True, copy=False,

Thank you, its working

supreeth
on 2/17/16, 1:36 AM
1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 2/16/16, 6:56 AM

Hi,

The suggestion in the link should work fine. You just need to specify the required fields:

vals_user = {

     'name': 'value_of_name',

     'login': 'login_password_value_eg_123', 

     ... and so on

You can check the required fields of the user here ...


Thanks, i need only login and password to be defined in my menu. how can we write that?

supreeth
on 2/16/16, 7:04 AM
0
supreeth
On 2/17/16, 1:36 AM

Hi all,

Thank you, it worked. I was getting 'Integrity error'. and it is solved.

def create(self, cr, uid, vals, context=None):
user_obj = self.pool.get('res.users')
vals_user = {
'name': vals.get('name'),
'login': vals.get('login'),
'password': vals.get('password'),
}
user_obj.create(cr, uid, vals_user, context)
result = super(users_profile, self).create(cr, uid, vals, context=context)
return result

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/16/16, 6:30 AM
Seen: 414 times
Last updated: 2/17/16, 1:36 AM