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 add field to One2Many with xpath expressions?

By
Yenthe
on 4/24/15, 3:21 AM 1,898 views

Hi guys,

I've been trying a few things to add a new field into a Many2one through xpath but I'm not sure why its not working. My model code:

 class aa_test(models.Model):
    _inherit = 'sale.order'
    hoogte = fields.Integer()
    breedte = fields.Integer()
    aantal = fields.Integer()

My view (xml):

 <openerp>
    <data>
        <record id="sale.view_order_form_inherit" model="ir.ui.view">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
 	    <field name="arch" type="xml">
		<xpath expr="//field[@name='order_line']" position="inside">
                    <field name="hoogte"/>
		</xpath>
	    </field>
        </record>
    </data>
</openerp>

en I change the position="inside" to position="before" I will see the field showing up before my One2many, when I put it on inside it wont be added to the One2many. I'm adding to the view under sales > Quotations to the One2many order_line. See this example image to see what I want.

Why is the before working but not the inside? Is my xpath expressions invalid?

Thanks,
Yenthe

2

Solanki Shamji

--Solanki Shamji--
1293
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

Solanki Shamji
On 4/24/15, 3:36 AM

Hello,

Please check again order_line is not a Many2one field. Its One2many field. This is the reason you cant use position=inside.

Try with this xpath I hope this will help you.

<xpath expr="//tree[@string='Sales Order Lines']/field[@name='name']" position="after">
    <field name="hoogte"/>
</xpath>

 Thanks.

Shamji.



Thanks Solanki, great answer! I've updated my question since I indeed named the field invalid. Another sidenode, I had to change my model from sale.order to sale.order.line, since its coming from that model! Thanks :)

Yenthe
on 4/24/15, 3:50 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

2 follower(s)

Stats

Asked: 4/24/15, 3:21 AM
Seen: 1898 times
Last updated: 4/24/15, 3:50 AM