Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
7 Vastaukset
7656 Näkymät

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

Avatar
Hylkää

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

Tekijä

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

Paras vastaus

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
Hylkää
Tekijä

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

Good point Ermin :)

Paras vastaus

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
Hylkää
Paras vastaus

Internal lottery :)

chosen = fired!

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
heinäk. 21
4176
3
heinäk. 25
6798
1
toukok. 25
1082
2
tammik. 25
1846
1
elok. 24
1881