Skip to Content
Menu
This question has been flagged
7 Replies
7653 Rodiniai

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

Portretas
Atmesti

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

Autorius

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

Best Answer

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

Portretas
Atmesti
Autorius

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

Good point Ermin :)

Best Answer

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

Portretas
Atmesti
Best Answer

Internal lottery :)

chosen = fired!

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
liep. 21
4162
3
liep. 25
6792
1
geg. 25
1081
2
saus. 25
1841
1
rugp. 24
1877