Odoo - Change domain on inherited view
<p>I am currently working on building a custom module, and I extended the unit of measure class (product.uom).  I want some uom entries to be removed from the list/tree views, based on a specific value for one of my new variables.</p>

<p>I am not entirely sure how to modify this view.  I seem to be reading that I need to specify a domain, like domain = [("myvariable","=",True)], but I'm not entirely sure how to apply this.  I tried inheriting the tree view, and adding a domain, but this doesn't work.</p>

<p>Any help would be greatly appreciated.</p>

<p>Solution:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;record model="ir.actions.act_window" id="uom_list_action"&gt;
    &lt;field name="name"&gt;Units Of Measurement&lt;/field&gt;
    &lt;field name="res_model"&gt;product.uom&lt;/field&gt;
    &lt;field name="domain"&gt;[("myvariable","!=",True)]&lt;/field&gt;
    &lt;field name="view_mode"&gt;tree,form&lt;/field&gt;
&lt;/record&gt;

&lt;record model="ir.ui.menu" id="product.menu_product_uom_form_action"&gt;
    &lt;field name="action" ref="uom_list_action"/&gt;
&lt;/record&gt;

&lt;record model="ir.ui.menu" id="stock.menu_stock_uom_form_action"&gt;
    &lt;field name="action" ref="uom_list_action"/&gt;
&lt;/record&gt;
</code></pre>

<p>In order to do what Nross2781 is looking for you have to override the ir.actions.act_window for the record. </p>

<pre><code>&lt;record model="ir.actions.act_window" id="uom_list_action"&gt;
    &lt;field name="name"&gt;Units Of Measurement&lt;/field&gt;
    &lt;field name="res_model"&gt;product.uom&lt;/field&gt;
    &lt;field name="domain"&gt;[("myvariable","!=",True)]&lt;/field&gt;
    &lt;field name="view_mode"&gt;tree,form&lt;/field&gt;
&lt;/record&gt;
</code></pre>

<p>However you may want to consider adding filters to a search view which would be more flexible. You would also be able to see the records which do not show up by default.</p>

<pre><code>&lt;record model="ir.ui.view" id="uom_search_view"&gt;
    &lt;field name="name"&gt;uom.search&lt;/field&gt;
    &lt;field name="model"&gt;product.uom&lt;/field&gt;
    &lt;field name="arch" type="xml"&gt;
        &lt;search string="Units Of Measurement"&gt;
            &lt;filter name="my_var_is_true" string="My Variable" domain="[('myvariable','=',True)]"/&gt;
            &lt;filter name="my_var_is_false" string="Not My Variable" domain="[('myvariable','!=',True)]"/&gt;
        &lt;/search&gt;
    &lt;/field&gt;
&lt;/record&gt;
</code></pre>

python filter openerp