Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
7 Trả lời
7733 Lượt xem

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

Ảnh đại diện
Huỷ bỏ

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

Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Good point Ermin :)

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Internal lottery :)

chosen = fired!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 21
4267
3
thg 7 25
7206
1
thg 5 25
1229
2
thg 1 25
2006
1
thg 8 24
1952