콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
7 답글
7727 화면

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
4258
3
7월 25
7162
1
5월 25
1212
2
1월 25
1992
1
8월 24
1948