In Odoo 19, form views are essential for presenting and managing data in a clear and interactive way. A form view focuses on a single record and provides users with the ability to create, view, and edit detailed information.
The form view system in Odoo is highly flexible, allowing developers to customize its structure and behavior through XML attributes. These attributes make it possible to adjust layouts, manage field visibility, define conditional behaviors, and fine-tune the user experience to match specific business needs.
When no custom attributes are applied, Odoo 19’s form view delivers the default set of features, such as adding new records, updating existing ones, deleting, or duplicating. Developers can extend this base functionality by introducing attributes that enhance usability and enforce business logic.
<record id="product_product_view_form" model="ir.ui.view">
<field name="name">product.product.view.form</field>
<field name="model">product.product</field>
<field name="arch" type="xml">
<form string="Products" create="0" edit="0" write=”0” delete="0" duplicate="0" disable_autofocus="1" js_class="product_product_form">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>
In Odoo 19, form views can be customized with attributes that control how users interact with records. These attributes define whether records can be created, modified, duplicated, or deleted, and they also allow developers to add advanced behaviors. Below are the most commonly used attributes:
- string
Defines the title of the form view. This label appears at the top of the form and helps users understand what type of record they are viewing or editing.
- create
Controls whether users can create new records in this form view. Setting create="0" (or false) hides the Create option.
- edit
Determines whether existing records can be edited. When set to edit="0", records open in read-only mode and cannot be modified.
- write
The write="0" makes the form read-only, preventing users from editing existing records
- duplicate
Enables or disables the Duplicate action. If set to duplicate="0", users will not see the duplicate option, which can prevent unwanted record copies.
- delete
Controls whether users can delete records from this form. Setting delete="0" disables the Delete button, useful when records must be preserved.
- js_class
Allows developers to attach a custom JavaScript class to the form view. This is useful for adding interactive or dynamic behaviors that go beyond the built-in features of Odoo.
- disable_autofocus
By default, Odoo focuses on the first editable field when a form opens. Setting disable_autofocus="1" disables this behavior, giving users control over where to start typing.
To disable these attributes, you can set them to 0, as shown below:
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="form_attribute_view_form" model="ir.ui.view">
<field name="name">form.attribute.view.form</field>
<field name="model">form.attribute</field>
<field name="arch" type="xml">
<form string="Form Attributes" create="0" write="0" delete="0" duplicate="0">
<sheet>
<group>
<field name="name"/>
<field name="date"/>
</group>
</sheet>
</form>
</field>
</record>
</odoo>
Odoo’s form views offer a flexible framework for working with records, but their real strength comes from the customization options provided through attributes. With attributes such as create, edit, duplicate, delete, and others, developers can precisely control how users interact with data. These options make it possible to restrict modifications, add custom JavaScript interactions, or adjust visibility based on business context. In Odoo 19, form view attributes remain a key part of tailoring the interface, allowing you to design forms that match both functional requirements and user experience goals.
To read more about Form View Attributes in Odoo 18, refer to our blog Form View Attributes in Odoo 18