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 do I access sub-components of a list field?

By
Jeff Beidler
on 9/9/14, 1:37 PM 947 views

If you go to the details page for a product and click on the "Procurements" tab, you'll see a list labeled "Suppliers".  Looking at the XML for the page, the only field I can see in this location is "seller_ids".  However, the list also shows "Delivery Lead Time" and "Minimal Quantity".  Are these fields somehow contained within "seller_ids", like an array?  I can't find any other views that add the other fields.  I would like to add "Product Name" and "Product Code" to the list.  I believe all of the fields are in the "product.supplierinfo" model.  How do I go about this?

1
Alex Gallien
On 9/10/14, 7:33 PM

If you check out addons/product/product.py, you'll see that 'seller_ids' is a one2many field pointing to 'product.supplierinfo' from 'product_id'. If you search for product.supplierinfo in addons/product/product_view.xml there are two records that reference it, "product_supplierinfo_form_view" and "product_supplierinfo_tree_view". The first of these is the the one that pops up when you click "Add an item" under suppliers, the second is the table that you are trying to edit. It looks like this:

 

        <record id="product_supplierinfo_tree_view" model="ir.ui.view">

            <field name="name">product.supplierinfo.tree.view</field>

            <field name="model">product.supplierinfo</field>

            <field name="arch" type="xml">

                <tree string="Supplier Information">

                    <field name="sequence" widget="handle"/>

                    <field name="name"/>

                    <field name="delay"/>

                    <field name="min_qty"/>

                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>

                </tree>

            </field>

        </record>

So what you'd have to do here is create a new module, inherit the "product_supplierinfo_tree_view" by using <field name="inherit_id" ref="product.product_supplierinfo_tree_view">, then add your fields using something like:

<record id="product_supplierinfo_tree_view_inherit" model="ir.ui.view">

    <field name="name">product.supplierinfo.tree.view</field>

    <field name="model">product.supplierinfo<field>

    <field name="inherit_id" ref="product.product_supplierinfo_tree_view">

        <field name="name" position="after">

            <field name="product_name"/>

            <field name="product_code"/>

        </field>

Since those columns are already in the 'product.supplierinfo' you don't even need to add any custom python code to your module.

 

Hope that helps! Cheers.

 

----

Alex Gallien

Information Officer LLC

E-mail: agallien@informationofficer.com

Web: www.informationofficer.com

Thanks for the detailed answer, Alex! I will try it out as soon as I get a chance. I think I saw that view when I was looking around, but don't remember seeing the other fields. Maybe it was a different one.

Jeff Beidler
on 9/15/14, 11:36 AM

Awesome, it works! I had searched for 'seller_ids' in product_view.xml, but it shows up somewhere else, not in the view to inherit. I didn't understand the connection made from the definition of 'seller_ids' in product.py to the view with the fields. I have a little better understanding of it now, but probably still not a total grasp. Thanks again!

Jeff Beidler
on 9/15/14, 2:22 PM

No problem. There is a lack of solid information out there on the inner workings of OpenERP - glad to be of use.

Alex Gallien
on 9/15/14, 4:51 PM

I also tried to override the field label by adding

Jeff Beidler
on 9/15/14, 5:21 PM

Doh! Guess you can't put XML code in comments. :\

Jeff Beidler
on 9/15/14, 5:22 PM

Try editing your original post and putting the code there.

Alex Gallien
on 9/15/14, 5:24 PM

I made a new question: https://www.odoo.com/forum/help-1/question/how-do-you-override-a-field-label-in-an-xml-view-62791 It would be nice if there were a code markdown feature for the forum. :)

Jeff Beidler
on 9/15/14, 5:29 PM
0
Marek Mosiewicz
On 9/10/14, 12:59 PM

There is special extension mechanism in Odoo. You can add fields to existing form in new module.

So your fields are added by addon modules.

 

http://consultantodoo.com

I knew that much. Can you provide further details as to how to access other fields from product.supplierinfo inside the _seller_ids_ field?

Jeff Beidler
on 9/10/14, 1:18 PM
What exactly you want navigate and form which class ? I you can navigate normally by fields even if it ends with _id

2014-09-10 19:18 GMT+02:00 Jeff Beidler <jeffb@videx.com>:

I knew that much. Can you provide further details as to how to access other fields from product.supplierinfo inside the _seller_ids_ field?

--
Jeff Beidler
Sent by OpenERP S.A. using Odoo about Forum Post False

Marek Mosiewicz
on 9/13/14, 5:24 AM

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: 9/9/14, 1:37 PM
Seen: 947 times
Last updated: 3/16/15, 8:10 AM