İçereği Atla
Menü
Bu soru işaretlendi
7 Cevaplar
7635 Görünümler

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

Avatar
Vazgeç

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

Üretici

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

En İyi Yanı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 :-)

Avatar
Vazgeç
Üretici

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

Good point Ermin :)

En İyi Yanı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

Avatar
Vazgeç
En İyi Yanıt

Internal lottery :)

chosen = fired!

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 21
4144
3
Tem 25
6746
1
May 25
1045
2
Oca 25
1799
1
Ağu 24
1841