Odoo Help

0

xpath for order_line field in sale order view

By
Wided
on 2/10/15, 5:01 AM 1,211 views

Hi,

I wrote an onchange_line() method in the sale_order class.

The method works well, but the problem is that I can't call it in the xml file:

<field name="arch" type="xml">
                <xpath expr="//page[@string='Order Lines']" position="replace">
                  <field name="order_line" on_change="onchange_line(order_line)" />
                </xpath>
            </field>

I get the error:

AttributeError: View definition error for inherited view 'sale.view_order_form_editable_list' on model 'sale.order': Element '<xpath expr="//field[@name='order_line']/tree">' not found in parent view 'sale.view_order_form'


I've tried many expressions for xpath but none works.

 

 

 

 

Just asking to make sure the question is for v7 or v8?

Dhinesh - Technical Consultant, Sodexis Inc
on 2/10/15, 5:04 AM

It's for v7, I'm sorry, I forgot to mention it.

Wided
on 2/10/15, 5:25 AM

specify the path correctly for "Order Lines"

aci aisha
on 2/10/15, 5:30 AM
1

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
4002
| 5 4 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 2/10/15, 5:28 AM

Instead of using replace, try to use attributes

<xpath expr="//field[@name='order_line']" position="attributes">
      <attribute name="on_change">onchange_line(order_line)</attribute>
</xpath>

when attribute is used at XPATH, you could define a particular attribute or option of the field instead of using replace to remove all attributes and adding the field definition to it.

For more info on XPATH: http://effbot.org/zone/element-xpath.htm

Good punch atchu(1 vote)

aci aisha
on 2/10/15, 5:34 AM

Thank you very much. It worked!

Wided
on 2/10/15, 5:36 AM
1

Ivan

--Ivan--
3245
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 2/10/15, 5:36 AM

There are 2 "problems" with your inheritance:

  1. You replaces a "page" tag with a "field" tag.  Generally it is not a good idea.
  2. If you objective is to change the order_line's on_change behaviour, it is not a good idea to "replace" the field with an incomplete definition.  A lot of things can go poof, including the "tree" element that is required by the same (in this case) or other modules in other views inherited from the same parent view (view_order_form).

A better way is just to change the attribute like so (in fact the erroneous view_order_form_editable_list view is a good example for this):

<xpath expr="//field[@name='order_line']" position="attributes">
          <attribute name="on_change">onchange_line(order_line)</attribute>
</xpath>

 

-1
Miel
On 2/10/15, 5:37 AM

Hi, try this one. Hope it helps. <xpath expr="//field[@name='order_line']" position="replace">

I've tried that but it didn't work

Wided
on 2/10/15, 5:42 AM

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.

Register

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

2 follower(s)

Stats

Asked: 2/10/15, 5:01 AM
Seen: 1211 times
Last updated: 3/16/15, 8:10 AM