I've faced several times the situation in which I need to write a Many2many
/One2Many
field in the left part of a domain and a simple record in the right part. Like the in
operator, but the other way around.
What I did is avoid this situation with workarounds, but now, I come up with nothing. My current situation is the following:
If you install project
module, you'll see that each project.task
object can have a unique responsible (user_id
, is a Many2one
). If you open tasks view, a filter is automatically loaded to see only your tasks:
<filter string="My Tasks" name="my_tasks" domain="[('user_id','=',uid)]"/>
But, what I need is to allow the assignment of several users to the same task. So first, I've create a Many2many
field in project.task
:
user_ids = fields.Many2many(
comodel_name='res.users',
string='Project Managers',
default=lambda self: self.env.user.mapped('id')
)
Everything works fine, however, now I need to make the filter work the same way as earlier, but with this field. Here is where I'm stucked and need an hypothetical operator contains
.
<filter string="My Tasks" name="my_tasks" domain="[('user_ids','contains',uid)]"/>
Did anyone deal with this situation? Any ideas?