Odoo Help

Welcome!

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.

0

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

By
E.M.
on 7/25/15, 11:19 AM 419 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"/>
</xpath>
</field>
</record>

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?


1

zbik

--zbik--
5976
| 6 4 7
Lodz, Poland
--zbik--


zbik
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!

E.M.
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)

Stats

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