Use of domain in search of One2many field in List view in Odoo-9
<p>i have One2many field <b>product_attributes</b> in <b>product.template</b> and <b>value</b> field in <b>product.attributes.custom</b></p>

<pre><code>class ProductTemplateCus(models.Model):
    _inherit = 'product.template'
    product_attributes = fields.One2many('product.attributes.custom','product_id')

class ProductAttributes(models.Model):
    _name = 'product.attributes.custom'
    value = fields.Char(string='Value')
    product_id = fields.Many2one('product.template',string='Product')
</code></pre>

<p>Product 1 <b>product_attributes</b> contains 2 values:</p>

<pre><code>value= 'color: red'
value= 'others: red'
</code></pre>

<p>product 2 <b>product_attributes</b> contains 2 values:</p>

<pre><code>value= 'color: white'
value= 'others: red'
</code></pre>

<p>I did like below in search xml:</p>

<pre><code>&lt;field 
name="product_attributes" string="Color"
filter_domain="['&amp;amp;',('product_attributes.value','ilike','color'),('product_attributes.value','ilike',self)]"
/&gt;
</code></pre>

<p>So if <b>red</b> is searched, only product 1 containing both <b>color</b> and <b>red</b> should be shown. But I am unable to get result. I am getting both products.</p>

<p>Is there any solution for this?</p>

<p>For solving my problem I used search function to get product ids which have selected attribute name and value only and included that in arguments in search function as</p>

<pre><code>args += [['id', 'in', productids]]
</code></pre>

<p>I don't know if it was a right approach to do it. But it solved my problem.</p>

python listview openerp odoo-9