This question has been flagged
1 Reply
6692 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...

Avatar
Discard
Best Answer

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

Avatar
Discard