I am using Odoo v.11.
I was trying to customize the search bar for my model, so that the user can look for a string matching the name or the description:
<record model="ir.ui.view" id="course_search_view">
<field name="name">course.search</field>
<field name="model">openacademy.course</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="description"/>
</search>
</field>
</record>
This seems to work, but the user has to specify if he's looking for the name or the description. Instead, I'd like that the user could search for a string, and the software should return every record matching that string in the name or description.
My idea was to define a computed field in the model, as the simple concatenation of field+" "+description:
text_data = fields.Char(string="Textual data", compute='_text_data')
@api.depends('name', 'description')
def _text_data(self):
for r in self:
r.text_data = str(r.name)+" "+str(r.description)
...and setup the search box to look for that field:
<record model="ir.ui.view" id="course_search_view">
<field name="name">course.search</field>
<field name="model">openacademy.course</field>
<field name="arch" type="xml">
<search>
<field name="text_data"/>
</search>
</field>
</record>
But this does not appear to work: the search always succeed, and all the records are returned even if the search string appears nowhere in the names and descriptions...
Am I doing something wrong?
Thanks in advance for any help.