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

How to Create openerp user through Python code ?

By
priyankahdp
on 10/17/13, 8:20 AM 3,801 views

How to Create openerp user through Python code ?

what are the required infor' ? [i tried below but its gives a error ]

res_users_obj = self.pool.get('res.users')
user_id = super(res_users, res_users_obj).create(cr, uid, {'login':'given_name' ,'password':'given_name'}, context=context)

my requirement is that , I need to create user when i'm create a employee

please help me to sort out this issue

1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 10/17/13, 10:58 AM

Hello,

here you need to override the create method of hr.employee.

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

Hope this will help you.

Thank you,

Serpent Consulting Services

can we add dictionary list for vals in below code line 'create(self, cr, user, vals, context=None):' for insert multiple records.?

priyankahdp
on 11/4/13, 5:44 AM

Why you need to add list of dictionary. As per your requirement it will be create a user at time of record creation.

Serpent Consulting Services Pvt. Ltd.
on 11/8/13, 7:13 AM

thanks dear friend now issue sorted :-)

priyankahdp
on 11/8/13, 7:31 AM

@priyankahdp, What is that default_login?

supreeth
on 2/5/16, 4:50 AM

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

0 follower(s)

Stats

Asked: 10/17/13, 8:20 AM
Seen: 3801 times
Last updated: 3/16/15, 8:10 AM