Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
7 Відповіді
7636 Переглядів

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
4145
3
лип. 25
6755
1
трав. 25
1062
2
січ. 25
1808
1
серп. 24
1846