Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
7 Răspunsuri
7623 Vizualizări

first, i want to get a list of users ids, and then choose randomly an id from that list

Imagine profil
Abandonează

Could you be more specific? What's the purpose of that?

Autor

i want to use this in a helpdesk module to assign tasks randomly to users.

Cel mai bun răspuns

The ID of the model res.users is an integer. So you could load the list and select one using a python random function, see for example https://docs.python.org/2/library/random.html.

But maybe you would rather use the model hr.employee to make sure you choose a real employee and not admin or sales or whatever :-)

Imagine profil
Abandonează
Autor

I used the random.choice() function, but it doesn't work!!

Good point Ermin :)

Cel mai bun răspuns

Better you use some another strategy instead of random selection because you could end up with overloaded users while others with nothing to do. I suggest a round robin strategy for that

Imagine profil
Abandonează
Cel mai bun răspuns

Internal lottery :)

chosen = fired!

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
iul. 21
4139
3
iul. 25
6721
1
mai 25
1035
2
ian. 25
1784
1
aug. 24
1829