コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
12579 ビュー

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
3267
1
10月 23
5219
1
6月 22
6434
4
6月 21
15746
0
4月 16
3131