This question has been flagged

In the module of the core 'sale' (sale_views) we can find the line:


<field name="order_line" string="Product" filter_domain="[('order_line.product_id', 'ilike', self)]"/>


When the filter is tested for 'cer' by Product, 60 sales orders appear, but if you export this data, 200 appear on the csv (e.g.).

The results of this csv are correct. Different sales orders also contain 'cert'.


According to https://www.odoo.com/documentation/12.0/reference/views.html#search the difference between filter_domain and domain is that in filter_domain you can use 'self'.


But by changing in the field 'filter_domain' to 'domain' the filter works:

<record id="view_sales_order_filter_fixed" model="ir.ui.view">

        <field name="name">view.sales.order.filter.fixed</field>

        <field name="model">sale.order</field>

        <field name="inherit_id" ref="sale.view_sales_order_filter"/>

        <field name="arch" type="xml">

            <field name="order_line" position="replace">

                <field name="order_line" string="Product" domain="[('order_line.product_id', 'ilike', self)]"/>

            </field>

        </field>

    </record>


Why does this happen? Can you use 'self' with 'domain' or is it a sales module error? 


Avatar
Discard
Best Answer

I searched the same thing, and this thread showed as 1st result without answer.
Whoever came across this, please, take a look at this answer.
https://www.odoo.com/forum/help-1/what-is-diff-between-domain-domain-filter-and-attr-21145

In short,
Domain are applied on relational fields (Many2one, One2many, Many2many) which restrict available selection when records are viewed in UI.
filter_domain is a search filter to best match given input by user, and it does not affect how records are actually stored.

Avatar
Discard