Odoo Help


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.


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

on 7/25/15, 11:19 AM 396 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?



| 5 4 7
Lodz, Poland

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

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

1 follower(s)


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