Odoo Help


How to create 'Search field' with group by feature ?

on 3/20/13, 5:48 AM 4,408 views

I need to create division field(many2one) and need to group them by their parent department wise. good example I got from hr_view.xml.they categorize by 'manager', 'coach', 'department', etc.. How to add this feature to my own many2one field.?

Please advice..

<record id="view_employee_filter" model="ir.ui.view">
    <field name="name">Employees</field>
    <field name="model">hr.employee</field>
    <field name="arch" type="xml">
        <search string="Employees">
            <field name="name" string="Employees"/>
            <field name="department_id" />
            <field name="category_ids" groups="base.group_hr_user"/>
            <group expand="0" string="Group By...">
                <filter string="Manager" icon="terp-personal" domain="[]" context="{'group_by':'parent_id'}"/>
                <filter string="Coach" icon="terp-personal" domain="[]" context="{'group_by':'coach_id'}"/>
                <filter string="Department" icon="terp-personal+" domain="[]" context="{'group_by':'department_id'}"/>
                <filter string="Job" icon="terp-gtk-select-all" domain="[]" context="{'group_by':'job_id'}"/>
                <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>

Create many2one field: 'division_id': fields.many2one('model name', 'Division'),

Create search field with group_by: <record id="view_name_filter" model="ir.ui.view"> <field name="name">xxx</field> <field name="model">model name</field> <field name="arch" type="xml"> <search string="xxx"> <field name="name" string="xxx"/> <field name="department_id"/> <group expand="0" string="Group By..."> <filter string="Division" icon="terp-personal" domain="[]" context="{'group_by':'division_id'}"/> /group> </search> </field> </record>

Where do you put this code? Is it in a View that inherits another view? Or in some other place? Does it need to inherit something or any other details?

Elephante, Sean Samborski
on 4/8/14, 7:33 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/20/13, 5:48 AM
Seen: 4408 times
Last updated: 3/16/15, 8:10 AM