2

How can I hide a filter in Odoo, I know I can use a record rule but in my case I can't. This is not working.

Please Note: This is not the filter I want to hide.

<filter name="today" **invisible="1"** string="Today's Investigation" domain="[('date','&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0))), ('date','&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]"/>
  • According to your comment below “ What i want is to make a filter of my own then hide it so that users cann't remove it ” your question is really badly written. – David V. Nov 05 '21 at 07:59

3 Answers3

0

The record rule is the best solution as far as i know an example of record rule on filter is

            <field name="name">ir.filters.own.rule.delete</field>
            <field name="model_id" ref="model_ir_filters"/>
            <field name="domain_force">[('user_id', '=', user.id)]</field>
            <field name="groups" eval="[(4, ref('base.group_user'))]"/>
            <field name="perm_read" eval="False"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
        </record> 
Derick
  • 159
  • 6
0

Check the solution How to make field readonly based on group and status? apply similar changes to your search view. I believe you need to show the filter to specific groups only.

OmaL
  • 5,037
  • 3
  • 31
  • 48
0

I don't understand utility of hide a filter. But if you want remove it, you can inherit the xml search view with the filter and xpath + replace the filter:

<xpath expr="//filter[@name='today']" position="replace">
</xpath>

The most importante in this code is position="replace".

jo541
  • 1,155
  • 6
  • 10