This question has been flagged
2 Replies
2524 Views

Hi,

I use the "auth_ldap" module that allows you to sync users between an LDAP server and Odoo.

I override the method to create the user to retrieve more informations like email or company.

The problem is that I use the multicompany feature and I can not associate multiple companies to an user.

I tried something like that but it does not work:

class Users(object):
    def __init__(self, name, company_id, company_ids, login, email):
        self.login = login
        self.company_id = company_id
        self.company_ids = company_ids
        self.login = login
        self.email = email

values = Users("Test TEST", 1, [1, 2, 3], "test.test", "test.test@test.fr")

self.env['res.users'].sudo().create(values)


Do you know how can I associate multiple companies to an user when it's created?

Best regards,

Robin Hède.

Avatar
Discard
Best Answer

Hello Robin Hede,

Can you please change your line like as below,

values = Users("Test TEST", 1, [(6, 0, [1, 2, 3])], "test.test", "test.test@test.fr")

Becuase its many2many field so syntax for it is like : (6, 0, [IDs]) .


Thanks,

Dipak

Avatar
Discard
Author Best Answer

Thank you for your response Dipak Shah, it works!

Avatar
Discard