Odoo Help

Welcome!

This community 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.

1

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

By
priyankahdp
on 3/20/13, 5:48 AM 3,010 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"/>
            </group>
        </search>
     </field>
 </record>
0

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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