Odoo Help


How is it added a new field in XML specifying on_change attribute at the same time?

on 7/25/15, 11:19 AM 698 views

To add a new field to a form in XML you just type:

    <record model="ir.ui.view" id="sale_margin_percent_3">
<field name="name">sale.order.line.tree.margin.view.form</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='price_unit']" position="after">
<field name="sale_margin_percent" groups="base.group_user"/>

which would add "sale_margin_percent" field after "price_unit" in "order_line".

So far, so good.

However, what would you need to add to specify that the new field has a given "on_change" attribute?

On 7/25/15, 12:14 PM

Try this:

<field name="sale_margin_percent" on_change="here_your_method(...)" groups="base.group_user"/> 

So simple, thanks!

on 7/25/15, 1:13 PM

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.


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

1 follower(s)


Asked: 7/25/15, 11:19 AM
Seen: 698 times
Last updated: 7/25/15, 1:13 PM