Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
7 Odpowiedzi
7626 Widoki

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

Awatar
Odrzuć

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.

Najlepsza odpowiedź

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 :-)

Awatar
Odrzuć
Autor

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

Good point Ermin :)

Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

Internal lottery :)

chosen = fired!

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lip 21
4142
3
lip 25
6729
1
maj 25
1039
2
sty 25
1788
1
sie 24
1833