Skip to Content
Menu
This question has been flagged
1 Reply
4549 Views

I'm using Odoo 13. My requirement is quite simple. I have a list of incidents. When I land on the tree view, I want to see a group_by filter that I have predefined to be applied by default. I've seen others implement this and done everything right, but still it doesn't work.  I can see the "Stage" filter in the group by dropdown but it doesn't get applied by default. I am pasting the code here for you to have a look. Please let me know if I'm missing something.

<record model="ir.ui.view" id="view_incident_incident_search">
<field name="model">incident.incident</field>
<field name="arch" type="xml">
<search>
<filter name="filter_group_by_stage" string="Stage" context="{'group_by': 'stage_id'}"/>
</search>
</field>
</record>

<record model="ir.actions.act_window" id="action_incident_window">
<field name="name">Incidents</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">incident.incident</field>
<field name="view_mode">tree,form,activity</field>
<field name="domain">[]</field>
<field name="search_view_id" ref="view_incident_incident_search"/>
<field name="context">{'default_search_filter_group_by_stage': 1}</field>
</record>
Avatar
Discard
Best Answer

Hi,

It is a typo in context try this:

    <field name="context">{'search_default_filter_group_by_stage': 1}</field>


Avatar
Discard
Author

I noticed people use this convention everywhere on the web and had tried this as well. In Odoo 12 Developer Essentials ebook written by Daniel Reis he specifies the 'default_search' prefix, that's why I've used it in my original post. But either ways, neither of these work. I don't know if I'm missing something more basic. Thanks for your suggestion though.

Author

Actually using 'search_default' worked. All this while I had failed to upgrade the app!!! That was the issue. Thanks Nikunj!!

Related Posts Replies Views Activity
1
Mar 15
12611
1
Sep 20
4567
2
May 17
7225
0
Oct 24
3
5
Nov 23
40240