Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
7 Antworten
7650 Ansichten

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

Avatar
Verwerfen

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.

Beste Antwort

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

Avatar
Verwerfen
Autor

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

Good point Ermin :)

Beste Antwort

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

Avatar
Verwerfen
Beste Antwort

Internal lottery :)

chosen = fired!

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Juli 21
4154
3
Juli 25
6787
1
Mai 25
1078
2
Jan. 25
1838
1
Aug. 24
1873