Odoo Help


How to access to fields from other object ?

on 5/20/14, 4:13 AM 2,142 views

Hi !

Here's my schema:

product.product -> product.template <- product.supplierinfo <- my_object

Now, in product.supplierinfo, I have a one2many field which is linked to my_object.

Question: How to display this one2many field as a tree in the product.product form ?

I inherit the product_normal_form_view. I tried with a relation field, but it seems that this kind of field can go only from product.product to product.template.

I also tried this :

    <?xml version="1.0" encoding="utf-8"?>
            <!-- views -->
            <record model="ir.ui.view" id="product_my_object_form_view">
                <field name="name">product.product.my_object.form</field>
                <field name="model">product.product</field>
                <field name="inherit_id" ref="product.product_normal_form_view"/>
                <field name="priority" eval="1"/>
                <field name="arch" type="xml">
                    <notebook position="inside">
                        <page string="My Object">
                            <field name="seller_ids">
                                <form version="7.0">
                                    <field name="name"/>
                                    <field name="my_object_ids">
                                            <field name="my_field1"/>
                                            <field name="my_field2"/>
                                            <field name="my_field3"/>
                                            <field name="my_field4"/>

But the normal form of product.supplierinfo overrided my own...

Dijoux Corentin
On 5/20/14, 8:43 AM

Hello PY,


I'm not sure to understand your schema ... You are in a view of "product.product" model. This model is link to "product.template" by what? A many2one i imagine? And product.template is link to "product.supplierinfo" by a one2many field i also imagine?


Now, if i understand your question, you need to display a tree of a special form :


<field name = "my_field1"/>

<field name = "my_field2"/>

<field name = "my_field3"/>

<field name = "my_field4"/>


But instead of display that, the tree display is the standard tree view from your view of "my_object"? Well, you can create a view into "my_object" with this tree and with a view_id and a name different from the other/standard tree view! ( explain here : https://doc.openerp.com/6.0/developer/2_6_views_events/views/specify_view_to_use/ ).


Then, when you need this special tree view, you can write this :

<field name="my_object_ids" mode="tree" context="{'tree_view_ref': 'YOUR_ID_OF_SPECIAL_TREE_VIEW'}"/>

Instead of :

<field name="my_object_ids">


<field name = "my_field1"/>

<field name = "my_field2"/>

<field name = "my_field3"/>

<field name = "my_field4"/>




Tell me if it works or not!


Corentin Dijoux

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: 5/20/14, 4:13 AM
Seen: 2142 times
Last updated: 3/16/15, 8:10 AM