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.

0

How to access to fields from other object ?

By
PY
on 5/20/14, 4:13 AM 1,238 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"?>
    <openerp>
        <data>
            <!-- 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">
                                        <tree>
                                            <field name="my_field1"/>
                                            <field name="my_field2"/>
                                            <field name="my_field3"/>
                                            <field name="my_field4"/>
                                        </tree>
                                    </field>
                                </form>
                            </field>
                        </page>
                    </notebook>
                </field>
            </record>
        </data>
    </openerp>

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

1
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 :

<tree>

<field name = "my_field1"/>

<field name = "my_field2"/>

<field name = "my_field3"/>

<field name = "my_field4"/>

</tree>

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">

<tree>

<field name = "my_field1"/>

<field name = "my_field2"/>

<field name = "my_field3"/>

<field name = "my_field4"/>

</tree>

</field>

 

Tell me if it works or not!

 

Corentin Dijoux

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

1 follower(s)

Stats

Asked: 5/20/14, 4:13 AM
Seen: 1238 times
Last updated: 3/16/15, 8:10 AM