Odoo Help


How to make two different listviews from the same model in a module?

on 11/27/14, 9:14 AM 1,218 views

Hi everybody

I want to extend the project module and make a new menu item that shows the project.project data in a listview but with other fields.
The default project listview looks like this:

I now want to create a second menu item that also shows a listview but with other field names. It should show me the name and some of my custom fields (such as x_internal_ip and x_external_ip).
How exactly should I do this? I've coded the second menu-item and the view but if I change the fields in the arch of project.project it reflects on both the project.project views that I now have.

My custom code:

    <record id="project_detail_tree" model="ir.ui.view">
            <field name="name">Details</field>
            <field name="model">project.project</field>
            <field name="arch" type="xml">
                <tree string="Details">
                    <field name="x_name"/>
            <field name="x_number"/>
            <field name="x_vm_name"/>
            <field name="x_internal_ip"/>
            <field name="x_external_ip"/>
            <field name="x_port"/>

        <record model="ir.ui.view" id="course_search_view">
            <field name="name">project.project.search</field>
            <field name="model">project.project</field>
            <field name="arch" type="xml">
                    <field name="name"/>

        <record model="ir.actions.act_window" id="project_course_action">
            <field name="name">Details overview</field>
            <field name="res_model">project.project</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        <field name="arch" type="xml">
                    <field name="name"/>

        <menuitem id="detail_menu" name="Details specifications" parent="base.menu_main_pm" />
        <menuitem id="project_details_menu" name="Details configuration" parent="detail_menu" action="project_course_action" />

The thing is that my code from project.project.tree is combined with the code of the default project.project tree code there is, which looks like this:

<record id="view_project" model="ir.ui.view">
            <field name="name">project.project.tree</field>
            <field name="model">project.project</field>
            <field name="field_parent">child_ids</field>
            <field name="arch" type="xml">
                <tree fonts="bold:message_unread==True" colors="red:date and (date&lt;current_date) and (state == 'open');blue:state in ('draft','pending');grey: state in ('close','cancelled')" string="Projects">
                    <field name="sequence" widget="handle"/>
                    <field name="message_unread" invisible="1"/>
                    <field name="date" invisible="1"/>
                    <field name="name" string="Project Name"/>
                    <field name="user_id" string="Project Manager"/>
                    <field name="partner_id" string="Contact"/>
                    <field name="parent_id" string="Parent" invisible="1"/>
                    <field name="planned_hours" widget="float_time"/>
                    <field name="total_hours" widget="float_time"/>
                    <field name="effective_hours" widget="float_time"/>
                    <field name="progress_rate" widget="progressbar"/>
                    <field name="state"/>

What is the solution to make a second view with data from project.project in a second tree view?


On 11/28/14, 4:25 AM

Yenthe, you need 2 actions in this case.  Within each action you can specify which views to use.  Bole has pointed out a good example file in ir.actions.act_window.view.  Search for "ir.actions.act_window.view" in that file for samples.

@John, thanks for the reply and some extra guidance! What I don't understand is why these two views interfere with eachother? I'm really missing the logic of this. Could you help me any further and give me a little sample or something? I'm really not sure about what to do. There are like three tree views in the sample too. :/

on 11/28/14, 4:35 AM

Yenthe, when Odoo executes a window action that does not specify any specify view, it will search for a view of that model and the requested type (tree, form, etc.) based on the order of priority and name. So, the higher the priority (the smaller the number), the more chance it will be picked up if a view is requested without specifying which specific one. The same goes for the name order if you have multiple views with the same priority. I'm not too sure what is the behaviour if you have multiple valid views with the same priority and name.

on 11/28/14, 5:14 AM

One more thing that you might have known before: trace the XML ids to see which view is used by which action.

on 11/28/14, 5:16 AM
On 11/27/14, 11:45 AM

You can find good example for similar thing in account module.. 
Check account_invoice_view.xml.... 
there is invoice_form and invoice_supplier_form views both "sitting" on same model.. 
Trick is to define separate actions , and in them define wich view should they call.. 

Take a closer look and apply to your models :) 
I see you are quite experienced, so no need for noob-like step-by-step expanation.. 

also.. hope this will help you a bit : )


@Bole, thanks for the reply! Sadly I can't seem to find my error. I know it has to do with the view it should call and the correction references but I just can't find what I'm doing wrong! Care to take a look at it and give me a bit more guidance? Looks like I'm missing something vital here.

on 11/28/14, 3:10 AM

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

1 follower(s)


Asked: 11/27/14, 9:14 AM
Seen: 1218 times
Last updated: 3/16/15, 8:10 AM