I added a new title field to a Sales Order. Now I want to also be able to search by that field in the sales order list view.
If I run the following code, it works, but it seems like an overkill:
<record id="view_sales_order_filter_inherit_sale" model="ir.ui.view">
<field name="name">sale.order.filter.toledo.sale</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<!-- <field name="name" position="attributes">
<attribute name="filter_domain">
"['|', '|',('name', 'ilike', self),('client_order_ref', 'ilike', self),'|',('partner_id', 'child_of', self),('title','ilike', self)]"
</attribute>
</field>
-->
<field name="name" position="replace">
<field name="name" string="Order"
filter_domain="['|', '|',('name', 'ilike', self),('client_order_ref', 'ilike', self),'|',('partner_id', 'child_of', self),('title','ilike', self)]"/>
</field>
</field>
</record>
I am looking for something more lean...like just replacing the domain for the "Order" filter...The following does not work:
<record id="view_sales_order_filter_inherit_sale" model="ir.ui.view">
<field name="name">sale.order.filter.toledo.sale</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="filter_domain">
"['|', '|',('name', 'ilike', self),('client_order_ref', 'ilike', self),'|',('partner_id', 'child_of', self),('title','ilike', self)]"
</attribute>
</field>
</field>
</record>
giving an error:
Caused by: InvalidDomainError: Invalid domain AST
Is it some issue with the domain itself or something else? Can I use the position "attributes" to achieve this?
From Odoo documentation:
if the
attribute
element has a body, a new attributed named after itsname
is created on the matched node with theattribute
element’s text as value
Odoo will add the quotes to the domain and make the domain incorrect, you need to remove the double quotes surrounding the domain list
If you get the following error:
ValueError: Invalid field %s in leaf %s
Add the field to the search view.