Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
7 ตอบกลับ
7624 มุมมอง

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!

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 21
4139
3
ก.ค. 25
6721
1
พ.ค. 25
1035
2
ม.ค. 25
1785
1
ส.ค. 24
1830