Reputation: 1142
This is my todo.task
odoo object
class TodoTask(models.Model):
_name='todo.task'
name=fields.Char('Description',required=1,help="what needs to be done")
is_done=fields.Boolean('Done?')
active1=fields.Boolean('Active?',default=True)
user_id=fields.Many2one('res.users','Responsible')
date_deadline=fields.Date('Deadline')
There are two menu items namely To-Do Tasks and To-Do Users which are of relevance here. I have created 4 ToDo which are responsible by 3 users(nicole,jack,Administrator). The menu item To-Do Tasks and its tree view works as intended, which has 4 entries.
When I press the To-Do Users I want to print all the unique users that are responsible for ToDOs, instead of this where nicole is repeated twice
currently its its tree view is as follows
<record id="view_tree_todo_users" model="ir.ui.view">
<field name="name">Employee data</field>
<field name="model">todo.task</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree >
<field name="user_id" />
</tree>
</field>
</record>
How can I list all the unique users in the second menu?
Upvotes: 0
Views: 369
Reputation: 769
you can't just hide duplicates from tree view because first 'nicole' and second 'nicole' are not same objects. They are two different object so when you asking to print 'user-id' it gives you this result.
One wrong way to hide duplicates in field user-id is unique constraint but if you will do this, then nicole can't create second task :D so it's bad idea.
I think from your model it's wrong to get unique names because it's normal that one person could have several tasks(it gives you correct results).
So if you want to get unique names then you must inherit 'res.users' and add some boolean field to res.users and then in tree view list all the users from 'res.users' where this boolean is true.
<field name="display_name" attrs="{'invisible':[('has_task','=',True)]}/>
Answer is not tested :) Hope it helped you.
Upvotes: 1