This question has been flagged
5 Replies
16478 Views

Hello, i've done many researches but i can't find anything on how to use this domain filter.

I would like to show, in my tree view, the records that only has a field 'fieldO2M' not empty.

For now, I find this incredibly hard to understand how domain works. I tried several things, the only one that went close to my goal was :

 

 attrs="{'invisible' :[('fieldO2M', '=', [])]}" as a field attribute

This one works but doesn't do what i want, it make the value of the field on which it is applied disappear. I want the all line to not be shown just like if i had used filter --> "fieldO2M" is defined.

After this I tried a lot of things that looks like this :

<field name="fieldO2M" domain="[(....."

But nothing that works or actually do something on my view.
Can someone explains me how the domain attribute works and how can I achieve my goal ?

I know that the domain definition is [('field','operation',value)] but i don't understand how to apply it to a field.

Thank you in advance ! :)

Avatar
Discard
Author

My goal is to create a filter that can't be exited. The filter I made :

<filter string="Matchings" name="filter_matchings" domain="[('fieldO2M', '!=', '[]')]"/>

Best Answer

Hi,

You can use domains on action view

<record model="ir.actions.act_window" id="action_id">
            <field name="name">action name</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">your model</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="search_view_id" ref="search_id" />
            <field name="domain">[('fieldO2M','!=',[])]</field>
        </record>

Best regards

Avatar
Discard
Author

Thank you ! I was using ir.actions.act_window.VIEW so i tried to put the domain in theses view actions. It has to be in the master Action Window to be effective. Thank you again !

Happy to help :)

Best Answer

Try:

domain="[('fieldO2M', '=', True)]"
Avatar
Discard