Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
8346 Lượt xem

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.

 

 

 

 

Ảnh đại diện
Huỷ bỏ

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

Tác giả

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

specify the path correctly for "Order Lines"

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

Good punch atchu(1 vote)

Tác giả

Thank you very much. It worked!

Câu trả lời hay nhất

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>

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

I've tried that but it didn't work

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 20
3683
1
thg 8 19
6355
1
thg 10 16
6499
1
thg 2 25
2537
3
thg 12 24
2232