I am trying to add an on_change attribute to 'purchase_price' field in a sales_order form. (It might require sales_margin module so purchase_price appears).
I add:
<record model="ir.ui.view" id="sale_margin_percent_5"> <field name="name">change.purchase_price</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']/tree//field[@name='purchase_price']" position="attributes"> <attribute name="on_change">update_sale_price(sale_margin_percent, purchase_price, discount)</attribute> </xpath> </field> </record>
But I get the following error:
Error details: Element '<xpath expr="//field[@name='order_line']/tree//field[@name='purchase_price']">' can not be located in parent view
Context error: View `change.purchase_price` [view_id: 621, xml_id: n/a, model: sale.order, parent_id: 577]" while parsing /usr/lib/python2.7/dist-packages/openerp/addons/custom/sale_margin_percent/sale_margin_percent.xml:27, near <record model="ir.ui.view" id="sale_margin_percent_5"> <field name="name">change.purchase_price</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']/tree//field[@name='purchase_price']" position="attributes"> <attribute name="on_change">update_sale_price(sale_margin_percent, purchase_price, discount)</attribute> </xpath> </field> </record>
Why "purchase_price" is not found? (I have added a similar on_change attribute for "price_unit" which works fine)