I need to hide or show a button depending on whether or not a Char field has a specific string in it. It seems that the 'like' operator would be perfect. In my xml, I have:
<record model="ir.ui.view" id="my_view">
<field name="name">my.form</field>
<field name="model">mymodule.my</field>
<field name="arch" type="xml">
<form string="My Form">
<header>
<button name="test_like_1" type="object"
string="Should not appear"
attrs="{'invisible':[('state2','like','measure')]}"
/>
<button name="test_like_2" type="object"
string="Should appear"
attrs="{'invisible':[('state2','not like','measure')]}"
/>
...
State2 contains 'measure,prelien', so I expect that the first button will be invisible and the second visible. However, both are invisible.
What am I missing?
Edit
I ran the query that I think Odoo would create from this domain -
select id, description, state2 from mymodule_my where state2 like '%measure%';
It runs as expected, returning the records that have "measure" as a substring. Somehow, this SQL isn't being generated/used. My next step is to dig through the Odoo code & see what's happening.
Can anyone provide insight to what's going on?