This question has been flagged
1 Reply
2904 Views

Hi, 

On OpenERP 7.0 (local install) I would like to:

- In the HRM module
- When creating an employee
- automatically create a related user for portal login

I'm sure it is possible but am looking for ideas on how :)..

 

thanks!

best, mark

Avatar
Discard
Best Answer

Override the "create" function on the hr.employee model in your own module. Then, create a portal user in the overwritten method, putting it in the values for your create method.

Something like:

class new_hr(osv.osv):

    _name = 'hr.employee'

    _inherit = 'hr.employee'

    def create(self, cr, uid, vals, context)

        my_variables = {<<list of name, groups, etc.>>}

        user_id = self.pool.get('res.users').create(cr, uid, my_variables)

        vals.update({'user_id': user_id})

        return super(new_hr, self).create(cr, uid, vals, context)

Avatar
Discard