Skip to Content
Menu
This question has been flagged
2 Replies
14618 Views

i'm using odoo 11 and i want to set a default filter which group by employee. i made a modification on the module but it doesn't shows the right result(i want to remove the administrator filter) .I don't know what's the problem .Any idea for help please ? 

<record id="action_bt_overtime_management" model="ir.actions.act_window"> <field name="name">Overtime</field> <field name="type">ir.actions.act_window</field> <field name="res_model">bt.hr.overtime</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="context">{'search_default_employee_id':1}</field> <field name="search_view_id" ref="bt_overtime_management_search"/> <field name="help" type="html"> <p class="oe_view_nocontent_create"> Create Overtime Request </p> </field> </record>

Avatar
Discard
Best Answer

1. In your search view, please add Group By filter

<record id="bt_overtime_management_search" model="ir.ui.view">
<field name="name">br.hr.overtime.search</field>
<field name="model">bt.hr.overtime</field>
<field name="arch" type="xml">
<field name="employee_id"/>
<group expand="0" string="Group By">
<filter name="group_employee" string="Employee" context="{'group_by':'employee_id'}"/>
</group>
</field>
</record>

2. And Define your filter as a default filter in your search view

<record id="action_bt_overtime_management" model="ir.actions.act_window">
<field name="name">Overtime</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bt.hr.overtime</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_group_employee': 1}</field>
<field name="search_view_id" ref="bt_overtime_management_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Create Overtime Request
</p>
</field>
</record>


Avatar
Discard
Best Answer

You want to set as group by employee but in your code given to filter only employee with id 1?

If you want to group use { 'group_by': 'employee_id'}


<record id="action_bt_overtime_management" model="ir.actions.act_window">
                <field name="name">Overtime</field>
                <field name="type">ir.actions.act_window</field>
                <field name="res_model">bt.hr.overtime</field>
                <field name="view_type">form</field>
                <field name="view_mode">tree,form</field>
                <field name="context">{'group_by':'employee_id'}</field>
                <field name="search_view_id" ref="bt_overtime_management_search"/>
                <field name="help" type="html">
                    <p class="oe_view_nocontent_create">
                        Create Overtime Request
                    </p>
                </field>
            </record>
Avatar
Discard
Related Posts Replies Views Activity
1
Dec 22
4422
2
Dec 22
13668
2
Jun 22
5519
2
Jun 22
4112
0
May 22
3427