Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
2022 มุมมอง

hello,,


i add new field to product.product model python

i want to Add it in product view form xml 

put i dont find view form for model product.product 

how can i add it 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Here’s the corrected and clarified XML code for adding a new field using an xpath expression while inheriting from product.product_normal_form_view:

<odoo>

    <record id="product_variant_custom_form_view" model="ir.ui.view">

        <field name="name">product.product.form.custom</field>

        <field name="model">product.product</field>

        <field name="inherit_id" ref="product.product_normal_form_view"/>

        <field name="arch" type="xml">

            <!-- Add the new field after the 'existing_field' field  -->

            <xpath expr="//field[@name='existing_field']" position="after">

                <field name="new_field_name"/>

            </xpath>

        </field>

    </record>

</odoo>


Regards,

Jishna

Accurates


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

thank you i use this code but it not add any thing and no errors ???

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The product.product model shares most views with product.template, but has its own specific form view product.product_normal_form_view. Here's how to inherit it:

<odoo>

    <record id="product_variant_custom_form_view" model="ir.ui.view">

        <field name="name">product.product.form.custom</field>

        <field name="model">product.product</field>

        <field name="inherit_id" ref="product.product_normal_form_view"/>

        <field name="arch" type="xml">

            <!-- Add your custom fields/modifications here -->

            

        </field>

    </record>

</odoo>

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 21
6740
0
เม.ย. 20
3553
1
ส.ค. 19
6241
1
ต.ค. 16
6431
5
ส.ค. 16
5662