İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
6717 Görünümler

Hello All,

I have 100+ users, some users have different-different groups

How can I achive this using python script or  what's the standard way to import it. ?

Thanks in Advance.



Avatar
Vazgeç
En İyi Yanıt

Hello Ankit,

based on the amount of data it depends.  if you have some validation on import like duplicate data will be skip and etc.. at that time you can use python script. 

1. using python script also you can import.

for eg.    self.env['res.users'].create({'name': 'abc', 'login': 'abc@mail.com', 'groups_id': [(6, 0, [list of groups ids])]})

2. using odoo's import feature you can import the .csv file and assign different groups to user as per below screen you can see.

https://prnt.sc/oaeae0

Avatar
Vazgeç
Üretici

Thanks @ Mitul +1

En İyi Yanıt

Hi Ankit,


You can import the user details using a csv file or an excel file. When I tried importing users the last day, it was taking an unusual amount of time. So I wrote a simple python function to create users and assign correct permissions. To set the correct permissions, find the field names of the permissions you need to apply while creating the users. These field name will be like 'sel_groups_1_9_10'. Just as the name suggests, those numbers are the values which the field can take. So create a list of dictionaries, with the users and their details. For example

users = [('name': 'Test', 'login': 'test@test.com', 'email': 'test@test.com', 'password': '', 'sel_groups_1_9_10': 1), ('name': 'Employee', 'login': 'employee')]

Now iterate over this list of dictionaries and create users based on these values.


for each in list:
    self.env['res.users'].create({'name': each['name'], 'login': each['email'], 'password': '',
'sel_groups_11_12': each['sel_groups_11_12'], 'sel_groups_17_18': each['sel_groups_17_18']})

This will create users with the corresponding values given in the list
Avatar
Vazgeç
Üretici

Thanks @ Mihran +1

İlgili Gönderiler Cevaplar Görünümler Aktivite
4
Haz 25
12130
2
Ağu 22
8183
1
Eki 23
97
4
Nis 23
11006
2
Eyl 21
2986