Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I am developing a module on OpenERP 7.0 to manage requests. Each request may (or may not) have an owner. The owner of a request belongs to some group and in a given moment he might want to give away his request to some other user in the same group. My question goes precisely in that direction. Having to select a user from res.users, how do I narrow his search possibilities to the users that belong to the same group?
Thanks in advance.
A little edit to thank René for is answer (comments still not working!) and to add some info.
I tried this but it didn't work for me (i'm opening a wizard that shows a dropdown menu to select a user from it, and I was trying to show the user only other users that belong to his group with a domain rule based on your sugestion.
<field name="assign_to" string="Assign to" domain="[('groups_id', 'in', [user.groups_id])]" />
But it says that "user" is not a valid global variable...
Thanks for that addicional tip, I already had tried it out, but it gave me a js error: Uncaught Error: AttributeError: object has no attribute 'groups_id'
I guess, I'll leave it this way (alowing them to search all) and pray that my users aren't stupid enough to give requests to other users that don't have permission to access them! :)
Since a user can be in more than one group this is not a tight search restriction (or maybe I have gotten you wrong?).
Anyway: Lets take UserA, who is in several groups (res.groups), and one wants to find all users (res.users) which are in any same group as UserA:
self.pool.get('res.users').search(cr, uid, [('groups_id', 'in', UserA.groups_id)])
If UserA is in HR/Employee and in Project/Manager this search will return all users that are employees OR (not xor) project managers.
Doing searchs on x2many fields is super tricky, so you might want to read more about it.
Hope that helps a little.
Thanks for the additional information.
Try your domain with [uid.groups_id].
I'm not sure if this helps, but it's worth a try.
Otherwise add a hidden field with the current user and set a default value for that field.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/22/14, 9:25 AM|
|Seen: 1728 times|
|Last updated: 3/16/15, 8:10 AM|