تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
7 الردود
7639 أدوات العرض

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
يوليو 21
4147
3
يوليو 25
6759
1
مايو 25
1065
2
يناير 25
1818
1
أغسطس 24
1848