コンテンツへスキップ
メニュー
この質問にフラグが付けられました
7 返信
7712 ビュー

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

アバター
破棄

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

著作者

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

最善の回答

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

アバター
破棄
著作者

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

Good point Ermin :)

最善の回答

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

アバター
破棄
最善の回答

Internal lottery :)

chosen = fired!

アバター
破棄
関連投稿 返信 ビュー 活動
1
7月 21
4217
3
7月 25
7039
1
5月 25
1163
2
1月 25
1939
1
8月 24
1939