How to Customize Odoo 19 Default One2many Form View

December 30, 2025 by
How to Customize Odoo 19 Default One2many Form View
Jasson
| No comments yet

One2many fields are a powerful feature in Odoo that allow you to display related records directly within a parent form. However, the default form view that appears when you click to add or edit a One2many record might not always meet your specific requirements. In this guide, we'll explore how to customize the One2many form view to create a better user experience.


Understanding One2many Fields

Before diving into customization, let's quickly review what One2many fields are. A One2many field represents a one-to-many relationship where one record can be linked to multiple records of another model. For example, a sales order (one) can have multiple order lines (many).


Why Customize the One2many Form View?

You might want to customize the default One2many form view for several reasons:

  • Show only relevant fields to reduce clutter
  • Change field layouts for better usability
  • Add custom widgets or field attributes
  • Include additional context or help text
  • Modify the form structure to match your workflow


Method 1: Inline Form View Definition

The simplest way to customize a One2many form view is by defining it directly within your field definition in XML.

xml
<field name="order_line">
    <list>
        <field name="product_id"/>
        <field name="quantity"/>
        <field name="price_unit"/>
    </list>
    <form>
        <group>
            <field name="product_id"/>
            <field name="product_description"/>
            <field name="quantity"/>
            <field name="price_unit"/>
            <field name="discount"/>
            <field name="tax_id" widget="many2many_tags"/>
        </group>
    </form>
</field>

This approach works well for simple customizations and keeps the form definition close to where it's used.


Method 2: Using form_view_ref Attribute

For more complex scenarios, you can reference a specific form view directly using the form_view_ref attribute. 

xml
<field name="order_line"
       form_view_ref="module_name.view_order_line_custom_form">
    <list>
        <field name="product_id"/>
        <field name="quantity"/>
        <field name="price_unit"/>
    </list>
</field>

Then define your custom form view separately

<record id="view_order_line_custom_form" model="ir.ui.view">
    <field name="name">order.line.custom.form</field>
    <field name="model">sale.order.line</field>
    <field name="arch" type="xml">
        <form>
            <sheet>
                <group>
                    <group>
                        <field name="product_id"/>
                        <field name="quantity"/>
                    </group>
                    <group>
                        <field name="price_unit"/>
                        <field name="discount"/>
                    </group>
                </group>
                <notebook>
                    <page string="Description">
                        <field name="product_description"/>
                    </page>
                </notebook>
            </sheet>
        </form>
    </field>
</record>


Conclusion

Customizing Odoo's One2many form views gives you the flexibility to create interfaces that perfectly match your business processes. Whether you choose inline definitions for simple cases or separate view records for complex scenarios, the key is to focus on user experience and maintain clean, maintainable code.

Start with small customizations, test thoroughly, and gradually build more sophisticated forms as you become comfortable with Odoo's view architecture. Your users will appreciate the tailored experience, and you'll benefit from more efficient data entry workflows.

How to Customize Odoo 19 Default One2many Form View
Jasson December 30, 2025
Share this post
Archive
Sign in to leave a comment