User Contacts filtered by department
Hi everyone.
I'm starting with oerp and I'm trying to filter user contacts, personaly and by department. I have created a record rule like that: ['|',('
The first part is just to filter the contacts created by the user and it works fine. The second part is where I have troubles. I want to save in a field, a list of the users id, from the departments of the creator user to finally compare with the user.id.
I'm working in a new class inherited from base_contact. To save the members of the user departments, first I use "browse" to get all the fields from the res.users table from the user creator. Then I use "browse" again with hr.department table to get the fild "member_ids" from this, and this way to save the users list from those departments.
Let me show you the code: I created a many2many related field with departments in res.users table named 'department_ids', like this:
class departments_
_inherit = 'res.users'
_columns = {
}
departments_user()
Also I created a field to save the department members list of the user:
'dep_aux'
This is the create function, where I'm trying to get list of members:
def create(self, cr, uid, vals, context=None):
user = self.pool.
departments = self.pool.
cnt = super(res_
return cnt
But when It has to save, I have an error: "AttributeError: 'int' object has no attribute '_table_name'"
I think that the mistake is the definition of the field dep_aux. What do you think? How would you do this?
First I thought in save the departments of the contact creator, and then compare with the departments of the current user, I think that this is more elegant, but I don't have any idea of how to do that.
Thank you very much for your time and your help. Thanks a lot.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- OpenERP Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Vinay Rana (OpenERP)
- Solved:
- Last query:
- Last reply: