Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
12583 Vues

Shortly. I would like to add on_change function to categ_id field in product.product_normal_form_view.

I have something like that:

<record id="product_normal_form_view_smart" model="ir.ui.view">
        <field name="name">product_normal.form.attribute</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.product_normal_form_view"/>
        <field name="arch" type="xml">
            <data>
                <xpath expr="/form/sheet/notebook" position="inside">
                        <field name="categ_id" on_change="on_change_categ_id()"/>
                </xpath>
            </data>
        </field>
    </record>

But it doesn't work, because now it adds new field. Problem is that I don't want add new field, only change existing one.

P.S. Of course I inherited product.product in py code.

Avatar
Ignorer
Auteur Meilleure réponse

Ok. I solved it.

<record id="product_normal_form_view_smart" model="ir.ui.view">
    <field name="name">product_normal.form.attribute</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view"/>
    <field name="arch" type="xml">
        <data>
               <field name="categ_id"  position="attributes">
                    <attribute name="on_change">on_change_categ_id()</attribute>
                </field>
        </data>
    </field>
</record>
Avatar
Ignorer
Meilleure réponse

If you want to replace the field "categ_id", why not use:

<record id="product_normal_form_view_smart" model="ir.ui.view">
    <field name="name">product_normal.form.attribute</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view"/>
    <field name="arch" type="xml">
        <data>
            <field name ="categ_id" position="replace">
                <field name="categ_id" on_change="on_change_categ_id()"/>
            </field>
        </data>
    </field>
</record>

Don't forget to add the method on_change_categ_id to your object product_product (if it doesn't exist).

Avatar
Ignorer
Publications associées Réponses Vues Activité
4
mars 24
3274
1
oct. 23
5228
1
juin 22
6441
4
juin 21
15750
0
avr. 16
3135