跳至内容
菜单
此问题已终结
2 回复
12625 查看

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.

形象
丢弃
编写者 最佳答案

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>
形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
4
3月 24
3348
1
10月 23
5322
1
6月 22
6554
4
6月 21
15827
0
4月 16
3223